观看vue.js 3设置
我已经将当前的vue.js代码更改为vue.js 3< script设置>代码,但是我对观看
属性有问题。 观看
< script设置>
中的正确语法是什么?
当前代码:
watch: {
config: {
handler(newConfig) {
if (this.$refs && this.$refs.range && this.$refs.range.noUiSlider) {
this.$refs.range.noUiSlider.destroy()
const newSlider = this.noUiSliderInit(newConfig)
return newSlider
}
},
deep: true,
},
}
在<脚本设置中的外观应该如何?
?
I've to change my current Vue.js code to Vue.js 3 <script setup> code, but I've problem with the watch
property. What is proper syntax for watch
in <script setup>
?
Current code:
watch: {
config: {
handler(newConfig) {
if (this.$refs && this.$refs.range && this.$refs.range.noUiSlider) {
this.$refs.range.noUiSlider.destroy()
const newSlider = this.noUiSliderInit(newConfig)
return newSlider
}
},
deep: true,
},
}
How should it look like in <script setup>
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
vue.js以其出色的文档而闻名 -
基本上:
显然,“您的代码”将不同 您当前拥有的内容,但是我认为您只需要使用
观看
而需要帮助。即,所有
this。*
在构图API中显然有所不同(在其中您永远不会使用this
)。值得注意的是,当您直接在反应式对象上调用Watch()时,它将隐含地创建一个深观察者 - 将在所有嵌套突变上触发回调:
-watcher在问题中,有这样的小型代码片段,很难说
config
是什么。Vue.js is known for its excellent documentation - Watchers (make sure you select composition API).
Basically:
Obviously, "Your code" will be different to what you currently have, but I assume you only needed help with how to use
watch
.i.e., all the
this.*
is obviously different in composition API (where you never usethis
).It's worth noting that When you call watch() directly on a reactive object, it will implicitly create a deep watcher - the callback will be triggered on all nested mutations: Deep Watchers
So, you may not even need the
deep:true
option - of course with such a small code fragment in the question, it's hard to say whatconfig
is.这样尝试。
Try it like this.