Vue.component('child', {
// 声明 props
props: ['msg'],
// prop 可以用在模板内
// 可以用 `this.msg` 设置
template: '<span>{{ msg }}</span>'
})
<!DOCTYPE html>
<html lang="en">
<head>
<script type="text/javascript" src="./vue.js"></script>
<meta charset="UTF-8">
<title>vue.js</title>
</head>
<body>
<pre>
//使用 props 传输资料予子组件
//props , data 重复名称会出现错误
</pre>
<div id="app1">
<child mssage="hello!"></child>
</div>
<script>
Vue.config.debug = true;
Vue.component('child', {
// declare the props
props: ['msg','nihao','nisha'],
// the prop can be used inside templates, and will also
// be set as `this.msg`
template: '<span>{{ msg }}{{nihao}}{{nisha}}</span>',
data: function() {
return {
mssage: 'boy'
}
}
});
var vm = new Vue({
el: '#app1'
})
</script>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<script type="text/javascript" src="./vue.js"></script>
<meta charset="UTF-8">
<title>vue.js</title>
</head>
<body>
<pre>
//使用 props 传输资料予子组件
//props , data 重复名称会出现错误
</pre>
<div id="app1">
<child mssage="hello!"></child>
</div>
<script>
Vue.config.debug = true;
Vue.component('child', {
// declare the props
props: ['msg','nihao','nisha'],
// the prop can be used inside templates, and will also
// be set as `this.msg`
template: '<span>{{ msg }}{{nihao}}{{nisha}}</span>'
});
var vm = new Vue({
el: '#app1'
})
</script>
</body>
</html>
<div id="app1"> <child msg="hello!"></child> <child nihao="hello1!"></child> <child nisha="hello2!"></child> </div>
Vue.config.debug = true;
Vue.component('child', {
// declare the props
props: ['msg','nihao','nisha'],
// the prop can be used inside templates, and will also
// be set as `this.msg`
template: '<span>{{ msg }}{{nihao}}{{nisha}}</span>',
/*data: function() {
return {
msg: 'boy'
}
}*/
});
var vm = new Vue({
el: '#app1'
})
<div id="app1"> <child msg="hello!"></child> <child nihao="hello1!"></child> <child nisha="hello2!"></child> </div>
Vue.config.debug = true;
Vue.component('child', {
// declare the props
props: ['msg','nihao','nisha'],
// the prop can be used inside templates, and will also
// be set as `this.msg`
template: '<span>123{{ msg }}{{nihao}}{{nisha}}</span>',
/*data: function() {
return {
msg: 'boy'
}
}*/
});
var vm = new Vue({
el: '#app1'
})
<div id="app1"> <child msg="hello!"></child> <child nihao="hello1!"></child> <child nisha="hello2!"></child> </div>
Vue.config.debug = true;
Vue.component('child', {
// declare the props
props: ['msg','nihao','nisha'],
// the prop can be used inside templates, and will also
// be set as `this.msg`
template: '<span>{{ msg }}{{nihao}}{{nisha}}123</span>',
/*data: function() {
return {
msg: 'boy'
}
}*/
});
var vm = new Vue({
el: '#app1'
})
<div id="app1"> <child msg="hello!"></child> <child nihao="hello1!"></child> <child nisha="hello2!"></child> </div>
Vue.config.debug = true;
Vue.component('child', {
// declare the props
props: ['msg','nihao','nisha'],
// the prop can be used inside templates, and will also
// be set as `this.msg`
template: '<span>{{ msg }}123{{nihao}}{{nisha}}123</span>',
/*data: function() {
return {
msg: 'boy'
}
}*/
});
var vm = new Vue({
el: '#app1'
})
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有