【发布时间】:2020-12-22 04:04:33
【问题描述】:
我正在尝试如何在不导致组件重新渲染的情况下改变文本输入中的道具。
这是我的代码
//App.vue
<template>
<div class="row">
<category-component v-for="category in categories" :key="category.title" :category="category" />
</div>
</template>
export default {
name: "App",
data() {
return {
categories: [
{
title: "Cat 1",
description: "description"
},
{
title: "Cat 2",
description: "description"
},
{
title: "Cat 3",
description: "description"
}
]
};
},
components: {
CategoryComponent
}
}
// CategoryComponent.vue
<template>
<div>
<input type="text" v-model="category.title">
<br>
<textarea v-model="category.description"></textarea>
</div>
</template>
当我更新文本输入时,组件重新渲染并且我失去焦点。但是,当我更新 textarea 时,它不会重新渲染。
任何人都可以对此有所了解吗?我显然错过了一些简单的 vue 反应性。
这是我的问题的基本codesandbox。
【问题讨论】:
标签: javascript vue.js