javascript - vue.js 是否可以在 inline-template 綁上方法或屬性
今天剛學習 vue 有一個問題想請教
假設我已經有一個 component 如下
1 2 3 4 5 6 7 8 9 | <code class = "js" > var Component = Vue.extend({
methods: function () {
print : function () {
console.log( 'Go' )
}
}
});
Vue.component( 'component' , Component);</code>
|
可否在 HTML 中直接 bind methods 呢?或者說該怎麼做能夠做到動態放入子元素但能用父元件的方法
1 2 3 | <code class = "html" ><component>
<button v-on:click= "print" > Print </button>
</component></code>
|