vue.js - 如何在 nativescript vue 中制作反应数组?
问题描述
我知道当我们直接使用索引设置项目时,vue 不会检测到数组的变化,而是使用 Vue.set,并且在 vue.js 中工作正常。但是我正在使用带有本机脚本的 Vue,当我使用 Vue.set(myArray,index,newValue) 时,会出错。ReferenceError Vue 未定义。这是我的脚本:
<script>
export default {
methods: {
comparar: function(caracter, pos) {
//This is NOT reactive
this.palabra_escrita[pos] = caracter
// This must be reactive but throws me error
app.$set(this.palabra_escrita, pos, caracter)
}
}, //End methods
data() {
return {
palabra_escrita: [],
};
}
};
</script>
这是我的 app.js 文件:
import Vue from 'nativescript-vue';
import HelloWorld from './components/HelloWorld';
// Uncommment the following to see NativeScript-Vue output logs
//Vue.config.silent = false;
new Vue({
template: `
<Frame>
<HelloWorld />
</Frame>`,
components: {
HelloWorld
}
}).$start();
解决方案
推荐阅读
- reactjs - Redux 用相同的动作连接多个组件
- excel - 我正在尝试选择所有具有多于一行的数字的行
- node.js - 如何通过cheerio获取图片网址?
- javascript - 每次以下代码中的“案例”更改时,如何刷新以下滑块的数组?
- c - C扫描用户输入(char),将其存储在变量中并与字符串进行比较
- c# - 如何使用 Visual Studio 代码将实体框架核心安装到 asp.net core 3 项目
- ecmascript-6 - 为什么使用 let 导致代码块中未定义?
- powershell - 如何将 powershell UTC 日期时间对象转换为 EST
- java - Java和hibernate一应用分离数据库
- c++ - 尽管我检查了空堆栈,但 C++ STL 堆栈弹出操作给出了段错误