小编Rob*_*bie的帖子

Vue.js 未捕获的类型错误:this.list.$remove 不是函数

我不断收到同样的错误,即 this.list.$remove 不是函数。我相信它与 html 标记有关,但不确定。任何人都可以指出我正确的方向吗?在过去的 2 天里,我一直在努力。

 Vue.component('cart-co', {

  template: '#cart-template',

  data: function() {
    return {
      list: []
    }
  },

  ready: function() {
    $.getJSON('cart/content', function(data) {
      this.list = data;
    }.bind(this));
  },

  methods: {
    removeItem: function(item) {
      console.log(item);
      this.list.$remove(item);
    }
  }
});


new Vue({
  el: 'body',
});
Run Code Online (Sandbox Code Playgroud)

这是我的购物车部分:

<cart-co></cart-co>

<template id="cart-template">
  <div class="cart-content-wrapper">
    <div class="cart-content" >
      <ul v-if="list" class="scroller" style="height: 250px;">

        <li v-for="item in list">
          <a href="item.html"><img src="assets/temp/cart-img.jpg" alt="" width="37" height="34"></a>
          <span class="cart-content-count">@{{ item.quantity }}</span>
          <strong><a href="item.html">@{{ item.name }}</a></strong>
          <em>@{{ item.price …
Run Code Online (Sandbox Code Playgroud)

javascript vue.js

5
推荐指数
1
解决办法
1万
查看次数

标签 统计

javascript ×1

vue.js ×1