我遵循使用组件加载视图的官方文档中描述的模式。其中一个组件有一个表单字段,我需要调用一个方法.tagsinput()
,因为我使用的是TagsInput。所以,像$('#tags').tagsinput()
. 这是我正在做的简化版本:
CreateBoardForm = Vue.extend
template: "<input type='text' v-text='tags' id='tags'/>"
data:
tags: ''
ready: ->
// this is where I'm hoping to access
// tags and call $('#tags').tagsinput() on it
// However, this.$el and this.template are all undefined
// I was hoping to do something like this.$el.find('#tags').tagsinput()
Vue.component('CreateBoardForm', CreateBoardForm)
vue = new Vue(
el: '#main',
data:
currentView: 'createBoardForm'
components:
createBoardForm: CreateBoardForm
)
任何有关如何初始化该表单字段的帮助将不胜感激。
谢谢