[英]Pass v-model value from one component to template
I am new in Vue.js and recently, I faced a problem that I should pass a value to the v-model of a template in main.js.我是 Vue.js 的新手,最近我遇到了一个问题,我应该将一个值传递给 main.js 中模板的 v-model。 I have the next template :我有下一个模板:
In main.js在 main.js 中
Vue.component("app-input", {
template: `
<b-row class="my-1 key">
<b-col sm="5" class="text_aln_rht">
<label>{{labelName}}</label>
</b-col>
<b-col sm="7">
<b-form-input
size="sm"
v-model="val"
></b-form-input>
</b-col>
</b-row>
`,
props: {
labelName: String,
val: String
},
methods: {
}
});
This is code from the component这是来自组件的代码
example.vue例子.vue
<app-input id="MF" name="TYPE_U32" labelName="test" val="Text"></app-input>
Thanks谢谢
You need to bind your prop value like below你需要像下面这样绑定你的道具值
<app-input id="MF" name="TYPE_U32" :labelName="test" :val="Text"></app-input>
If your prop value is not data ( just string ) , use single squote
如果您的道具值不是数据(只是字符串),请使用single squote
<app-input id="MF" name="TYPE_U32" :labelName="'test'" :val="'Text'"></app-input>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.