<template?id="panel-tpl">
????<div>
????????<div?class="title"?v-on:click="alertTitle">
????????????蛤蛤
????????</div>
????????<div?class="content">
????????????茍利國(guó)家生死以
????????</div>
????????<div?class="footer">
????????????將信將疑
????????</div>
????</div>
</template>
<div?id="app"?class="app">
????<panel></panel>
</div>$(function(){
????Vue.component("panel",?{
????????template:?"#panel-tpl",
????????methods:?{
????????????alertTitle:?function(){
????????????????console.log(this.mess);
????????????}
????????}
????})
????var?app?=?new?Vue({
????????el:?"#app",
????????data:?{
????????????mess:?"實(shí)例中的mess"
????????}
????})
????
})我想點(diǎn)擊一下【蛤蛤】,打印一下#app中的mess,請(qǐng)問(wèn)如何做到?現(xiàn)在因?yàn)榻M件中沒(méi)有mess這個(gè)屬性,打印undefined.
vue組件如何訪問(wèn)對(duì)象實(shí)例中的屬性?
慕先生4543078
2018-01-17 11:05:00