我有一个这样的模板:
<template>
<div>{{hello}}</div>
</template>
<script>
export default {
data() {
hello: "Hello World!",
secret: "The answer is 42"
}
}
</script>
如何从 Chrome 调试控制台获取和操作 secret
的值?
我已经安装了 Vue 扩展,它允许我查看我的组件并查看变量。我想做的是获取这些变量并对其进行操作。
这可能吗?
最佳答案
Vue.js 论坛上也有类似的讨论。具体来说,SevenLines post on Mar 25 2018阅读:
Update from 2018. If you use vue-devtools, you can access Vue from console by selecting desired component, and then accessing it through $vm variable. Check the image with example:
关于vue.js - 如何从 JS 控制台访问 Vue 组件中的变量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51848439/