<template?id="panel-tpl">
????<div>
????????<div?class="title"?v-on:click="alertTitle">
????????????蛤蛤
????????</div>
????????<div?class="content">
????????????茍利國家生死以
????????</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:?"實例中的mess"
????????}
????})
????
})我想點擊一下【蛤蛤】,打印一下#app中的mess,請問如何做到?現在因為組件中沒有mess這個屬性,打印undefined.
vue組件如何訪問對象實例中的屬性?
慕先生4543078
2018-01-17 11:05:00