Vuejs2 在vue中重复使用相同的v-app
我有下面的pug/html:Vuejs2 在vue中重复使用相同的v-app,vuejs2,Vuejs2,我有下面的pug/html: table.accountinfo.table.table-sm thead.thead tr th # th Name th Address th Balance tbody t
table.accountinfo.table.table-sm
thead.thead
tr
th #
th Name
th Address
th Balance
tbody
tr(v-for="account in accounts")
td {{account.accountID}}
td {{account.name}}
td
span(title='{{account.accountAddress}}').ellipsisoverflow {{account.accountAddress}}
td
span {{account.balance}}
table.accountinfo.table.table-sm
thead.thead
tr
th #
th Name
th Address
th Balance
tbody
tr(v-for="account in accounts")
td {{account.accountID}}
td {{account.name}}
td
span(title='{{account.accountAddress}}').ellipsisoverflow {{account.accountAddress}}
td
span {{account.balance}}
以及下面的vue脚本:
var accountinfo = new Vue({
el: '.accountinfo',
data: {
accounts: []
}
});
当我打开html文件时,只正确创建了第一个表(多行数据正确)。但是,第二个表没有正确创建,它显示了包括括号在内的值(因此没有被vue替换)。我假设是这样的,因为同一个v-app使用了两次。我如何配置它,以便使用相同的v-app正确创建两个元素/表?我不认为它是专门写在任何地方的,但根据使用ids完成的链接,这是为了确保一个vue实例仅链接到一个根元素 不可能在多个元素上装载一个应用程序 根据您的编辑,您有两种方法来做您想做的事情:
帐户
变量中读取我不认为它是专门写在任何地方的,但根据链接是用ids完成的,这是为了确保一个vue实例只链接到一个根元素 不可能在多个元素上装载一个应用程序 根据您的编辑,您有两种方法来做您想做的事情:
帐户
变量中读取您在哪里使用
v-model
?代码的第一个问题是您不能将一个vue应用程序装载到多个元素!V-model应该是V-app,我在问题中对此进行了更新。您描述的问题实际上是我的问题,我想将1个vue应用程序装载到多个元素。这在任何情况下都是可能的还是不是一个选项?您在哪里使用v-model
?您的代码的第一个问题是您不能将一个vue应用程序装载到多个元素!V-model应该是V-app,我在问题中对此进行了更新。您描述的问题实际上是我的问题,我想将1个vue应用程序装载到多个元素。无论如何,这是可能的还是不可能的?