Codeigniter,Vue,错误未转移未定义

时间:2018-10-30 16:19:57

标签: php codeigniter vue.js

enter image description here,这是我的addNewLane函数,可以在我的php应用程序的另一部分正常工作

    addNewLane: function () {
                this.addingNewLane = true
                this.editingLane = true
                this.editingLaneRow = 0

                let lane = new Lane()
                this.customerSelected.unserialized_lanes.unshift(lane)

            },

我在点击时称呼它,但出现错误

<div v-if="customerSelected.type == 'billing'" class="col-lg-12">
                    <div class="form-group">
                        <label class="col-sm-1 control-label">Lanes</label>
                        <a v-on:click="addNewLane" style="float: right;"><i class="fa fa-plus"></i>&nbsp;Add</a>
                        <div class="responsive-table col-sm-12">
                            <table class="table table-hover">
                                <thead>
                                    <tr>
                                        <th>From</th>

                                        <th>To 1</th>

这是我得到的错误:

> Uncaught TypeError: Cannot read property 'unshift' of undefined
    at VueComponent.addNewComment (billing:581)
    at invoker (vue.js:2029)
    at HTMLAnchorElement.fn._withTask.fn._withTask (vue.js:1828)

我是Codeigniter和Vue的新手。

 // lanes
        if (isset($data->unserialized_lanes)) {
            $insertArray['lane_lists'] = serialize($data->unserialized_lanes);
        }

        if(!empty($id)){
            $insertArray['updated_at']=time();
            $this->admin_model->updateCustomer($id,$insertArray);
            $this->session->set_flashdata('success_msg', 'Customer updated successfully');
        }else{
            $insertArray['created_at']=time();
            $insertArray['created_by']=$this->session->userdata('logged_in')['id'];
            $id=$this->admin_model->addCustomer($insertArray);
            $this->session->set_flashdata('success_msg', 'Customer added successfully');
        }
        echo "success";
    }else{
        echo json_encode($errors);
    }


var vm = new Vue({
    el: "#editCustomer",
    data: {
        loginUserType:   <?php echo $this->session->userdata('logged_in')['type']; ?>,
        customerSelected: <?php if(!empty($record)) echo json_encode($record); else echo '{}'; ?>,
        states:          <?php echo json_encode($this->config->item('us_states')); ?>,

        addingNewLane: false,
        editingLane: false,
        editingLaneRow: null,

        hasSameAddress: false,

        isActive: false,

        isApproved: false,
        errors: [],

    },

0 个答案:

没有答案