admin管理员组文章数量:1422437
I installed vue-cli
and made some ponents, and everything was working great until I had to update some object values with keys
obj = {
key1: value1,
key2: value2,
key3: value3
};
The data is updating, but the view isn't updating and when I dig into Vue documentation it says
Due to limitations in JavaScript, Vue cannot detect the following changes to an array:
- When you directly set an item with the index, e.g. vm.items[indexOfItem] = newValue
The solution would be to use Vue.set()
but when try that (inside my ponent) I get the following result:
Vue.set(example1.items, indexOfItem, newValue);
Uncaught ReferenceError: Vue is not defined
I installed vue-cli
and made some ponents, and everything was working great until I had to update some object values with keys
obj = {
key1: value1,
key2: value2,
key3: value3
};
The data is updating, but the view isn't updating and when I dig into Vue documentation it says
Due to limitations in JavaScript, Vue cannot detect the following changes to an array:
- When you directly set an item with the index, e.g. vm.items[indexOfItem] = newValue
The solution would be to use Vue.set()
but when try that (inside my ponent) I get the following result:
Vue.set(example1.items, indexOfItem, newValue);
Share Improve this question edited Jul 14, 2022 at 0:53 tony19 139k23 gold badges278 silver badges348 bronze badges asked May 1, 2017 at 12:29 Shon LeviShon Levi 1483 silver badges14 bronze badges 3Uncaught ReferenceError: Vue is not defined
- Show the code where you define and trying to change this object. – Egor Stambakio Commented May 1, 2017 at 14:03
-
5
Make sure your ponent imports the Vue module at the top of the file or at the top of the script section:
import Vue from 'vue';
– Philipp Gfeller Commented May 1, 2017 at 15:31 - 1 Great, that's work :) – Shon Levi Commented May 1, 2017 at 15:41
2 Answers
Reset to default 6You probably forgot to import your Vue in the ponent you're in
import Vue from 'vue';
This should solve
You forget the most important thing to introduce vue. The simplest, we can directly in the html file in the script tag to introduce vue, such as:
<script src="https://cdn.bootcss./vue/2.3.3/vue.min.js" type="text/javascript" charset="utf-8"></script>
In projects that use vue, individuals do not remend configuring webpack and vue-loader separately. You can directly use vue official scaffolding, vue-cli. Do not have to consider these configurations, automatically configured.
vue-cli
If you just started learning Vue, here's an entry-level demo. Although it is only a small application, but it covers a lot of knowledge points (vue2.0 + vue-cli + vue-router + vuex + axios + mysql + express + pm2 + webpack), including front-end, back-end, database and other sites Some of the necessary elements, for me, learning great significance, would like to encourage each other!
Vue Demo
本文标签:
版权声明:本文标题:javascript - Using vue-cli, components throw "Uncaught ReferenceError: Vue is not defined" - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745359330a2655223.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论