0
模板:vueJS 2,如何綁定的JavaScript動態組件
<template v-for="(item, i) in items">
<v-divider
v-if="item.divider"
class="my-4"
:key="i"
></v-divider>
<v-list-tile
:key="i"
v-else
:to="item.to"
>
<v-list-tile-action>
<v-icon>{{ item.icon }}</v-icon>
</v-list-tile-action>
<v-list-tile-content>
<v-list-tile-title>
{{ item.text }}
</v-list-tile-title>
</v-list-tile-content>
</v-list-tile>
</template>
腳本部分:
export default {
name: 'sideMenu',
data() {
return {
toggleKeyboardShortcuts: false,
items: [
{ icon: 'add', text: 'Create new question', to: '/question' },
{ divider: true },
{ icon: 'lightbulb_outline', text: 'Notes', to: '#' },
{ icon: 'touch_app', text: 'Reminders', to: '#' },
{ divider: true },
{ icon: 'settings', text: 'Settings', to: '#' },
{ icon: 'help', text: 'Help', to: '#' },
{ icon: 'keyboard', text: 'Keyboard shortcuts', events: { 'click': this.toggleKeyboardShortcutsDialog.bind(this) } },
{ icon: 'phonelink', text: 'App downloads', to: '#' }
]
}
},... more stuff, but not relevant for this question
我能夠通過不同的屬性和事物正確渲染,但是當點擊該列表的項目失敗時,傳遞JavaScript函數來執行。我需要這種行爲觸發一個對話框(使用路由器的作品訪問頁)
您是否嘗試過利用'@點擊「屬性? – Derek
像'@點擊= 「item.js」'的'v型for'循環?我不確定我會在幾分鐘內嘗試試用 –
似乎不起作用。 –