在做我的前端 Vue 项目时,当元素被推入列表中时,我需要执行某些步骤data。但是,当我将一些初始值推入 中的列表时mounted(),console.log()相应的 中和参数值watch()输出相同的值。newValoldVal
JavaScript/Vue 代码:
let app = new Vue({
el: "#app",
data: {
testList: [],
},
mounted: function() {
this.testList.push('a');
this.testList.push('b');
this.testList.push('c');
},
watch: {
testList: {
handler: function(newVal, oldVal) {
console.log("new", newVal);
console.log("old", oldVal);
},
},
}
});
Run Code Online (Sandbox Code Playgroud)
newVal具有oldVal相同的值?watch()被执行三次(因为我在 中推送了三次mounted())?我开始使用 VSCode Insiders,并希望将我的稳定版本扩展同步到 Insider。根据官方文档,我需要选择“稳定”作为同步服务。然而,我第一次启动设置同步并选择“Insiders”时并没有注意到这一点。我找不到如何在设置/VSCode 命令面板中将其更改为“稳定”;注销并重新登录不起作用;重新安装 VSCode Insiders 不起作用。
如何将服务更改为稳定版?
我正在使用 Vagrant 在 Windows 上设置 C++ 开发环境。我成功安装并启动了我的虚拟机;停止和重新启动 VM 也没有产生任何错误。但是这次执行“vagrant up”显示:
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'bento/ubuntu-20.10' version '202107.07.0' is up to date...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
==> default: Forwarding ports...
default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
There …Run Code Online (Sandbox Code Playgroud) javascript ×1
nginx ×1
server ×1
url ×1
vagrant ×1
virtualbox ×1
vue.js ×1
wiki.js ×1
windows ×1