Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/368.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript &引用;v代表;Vue.js的输出错误“;TypeError:无法读取属性';标签';“未定义”的定义;_Javascript_Vue.js - Fatal编程技术网

Javascript &引用;v代表;Vue.js的输出错误“;TypeError:无法读取属性';标签';“未定义”的定义;

Javascript &引用;v代表;Vue.js的输出错误“;TypeError:无法读取属性';标签';“未定义”的定义;,javascript,vue.js,Javascript,Vue.js,我正在使用Vue.jsv1.0.21并尝试打印按钮 html: ... <span id="buttons" v-for="button in buttons" track-by="$index"> <input type="button" value="{{ button.label }}" /> </span> ... js: var v = new Vue({ el: '#buttons', data: { butt

我正在使用Vue.jsv1.0.21并尝试打印按钮

html:
...
<span id="buttons" v-for="button in buttons" track-by="$index">
  <input type="button" value="{{ button.label }}" />
</span>
...

js:
var v = new Vue({
    el: '#buttons',
    data: {
        buttons: [
            { label: 'foo' },
            { label: 'bar' },
            { label: 'baz' },
        ],
    },
});
html:
...
...
js:
var v=新的Vue({
el:'按钮',
数据:{
按钮:[
{标签:'foo'},
{标签:'bar'},
{标签:'baz'},
],
},
});
当我执行此代码时,3个按钮被正确打印。但是,计算表达式“button.label”时出错:TypeError:无法读取我的控制台中出现的未定义属性“label”


这段代码有错误吗?

刚刚试过,效果很好。也许您的错误来自代码的另一部分?谢谢你的回答。我不知道为什么它能工作,但我更新了html如下,工作得很好@nils这只是一个警告,因此如果使用vue.min.js,它将被抑制。如果您使用fiddle并改用vue.js,您会看到有问题的错误:只需在fiddle中尝试,它就可以正常工作。也许您的错误来自代码的另一部分?谢谢你的回答。我不知道为什么它能工作,但我更新了html如下,工作得很好@nils这只是一个警告,因此如果使用vue.min.js,它将被抑制。如果您拿起小提琴,改用vue.js,您会看到有问题的错误: