数据通过道具不会被渲染通过使用时
问题描述:
我有一个分量这样看,界定“名”和“占位”性质:数据通过道具不会被渲染通过使用时
Vue.component("text-control", {
props: {
name: String,
placeholder: {type: String, default: ""},
},
template: '<div class="form-group"><label>{{name}}</label> <input class="form-control" type="text" placeholder="{{placeholder}}"></div>'
});
叫一样,我的网页上:
<text-control name="Name" placeholder="Enter Name here"></text-control>
名称属性被正确解析。但我无法获得占位符属性值的工作。它显示我{{placeholder}}
而不是Enter Name here
。我如何将属性绑定到模板中的属性值?
答
在Vue公司2.0,您不能使用属性{{}}
等,您应该使用V-绑定:
<input class="form-control" type="text" v-bind:placeholder="placeholder">