如果这是关于安排哪个组件将出现在另一个组件之后。让我假设我拥有一个数组中的所有组件,并且可以将它们重新排列为数组中的逻辑,并且可以使用特殊属性is来渲染这些组件。
在这里,在样品我有分量的数组和我使用v-for
来呈现那些接二连三:
见拨弄here。
HTML:
<div id="app">
<h1>
Following are the components
</h1>
<div v-for="comp in compArray" :is="comp"></div>
<br>
<button @click="resuffle">
Resuffle
</button>
</div>
<template id="comp1">
<div>
<span>This is component 1</span>
</div>
</template>
<template id="comp2">
<div>
<span>This is component 2</span>
</div>
</template>
<template id="comp3">
<div>
<span>This is component 3</span>
</div>
</template>
JS:
Vue.component('comp1', {
template: '#comp1',
})
Vue.component('comp2', {
template: '#comp2',
})
Vue.component('comp3', {
template: '#comp3',
})
new Vue({
el: '#app',
data: {
compArray: ['comp1', 'comp2', 'comp3']
},
methods: {
resuffle: function() {
this.compArray.push(this.compArray[1])
this.compArray.splice(1,1)
}
},
})
你可以得到的信息是什么我想在这里实现:http://stackoverflow.com/questions/41415523/how-to-insert-vue-component-in-dynamic-position 无论如何,这不会是一个项目数组。我想在不同的地方显示单个组件(在点击面板的行后面)。 – Sovon