Vue.js 遍历数组并添加新元素: x0, y0
<template>
<div>
<div v-for='(item, index) in x' :key='index'>
<p>x{{index}}:{{item}}</p>
<p>y{{index}}:{{y[index]}}</p>
</div>
</div>
</template>
<script>
export default {
data() {
return {
x: [1, 2, 3],
y: [2, 4, 6]
};
},
methods: {
addxy() {
this.x.push(0);
this.y.push(0);
}
}
};
</script>
原文地址: http://www.cveoy.top/t/topic/lknm 著作权归作者所有。请勿转载和采集!