Vue复习笔记-2018-07-16

template模板:
html代码很少时写在new Vue的选项里
template:`<h2 style='color:red'>我是选项里的template模板</h2>`

html较多:
<template id="demo2">
    <h2 style='color:red'>我是template标签模板</h2>
</template>
在选项中添加:
template: "#demo2"

<script type="x-template" id="demo3">
    <h2 style='color:red'>我是script标签模板</h2>
<script>
在选项中添加:
template: "#demo3"

全局component:
Vue.component('zmj',{
    template:`<h2 style='color:red'>我是选项里的template模板</h2>`
})
局部component(在new Vue())选项中添加:
components:{
    'zmj':{
          template:`<h2 style='color:red'>我是选项里的template模板</h2>`
     }
}

<zmj here="China" ><zmj>
components:{
    "zmj":{
          template:`<div style="color:red"> {{ here }} </div>`,
          props:['here']
     }
}
带横线"-"的属性处理   from-here 转为 fromHere即可
属性传值    :here = "message"       在data中定义message的值

父子组件
var city = {
    template:`<div>siChuan of China</div>`
}
var zmj = {
    template:`<div>
                           <p>Panda from China</p>
                           <city></city>
                     </div>`,
    components:{
          "city": city
     }
}

<component>标签
<component :is="who"></component>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值