javascript - vue mounted After calling the method method, the post in the method reports an error.
高洛峰
高洛峰 2017-06-26 10:55:40
0
2
2593

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all(2)
Ty80

The error reported is the post attribute TypeError (the engine will report this error when referencing attributes in values ​​of null or undefined type), so this.$http should not exist in your vue. Check whether vue-resource is not imported, or the import position is wrong. If there are still problems, it is recommended to check the use of vue-resource.

为情所困

Solved, first of all, I would like to state that I am a beginner, I don’t use node, it is just in the form of html plus Js, and js uses Vue.
The problem is that if you use post and get in method, it can be used normally. It was introduced in html

<script src="vue/vue-resource.js"></script>;

But in the same situation, when using post etc. in mounted, an error is reported. Mounted shouldn’t mean that all pages have been mounted! I don’t understand. Anyway, vue-resource.js is not found.
Solution:
in html

<script src="vue/userVue.js">
  var Vue = require('https://unpkg.com/vue/dist/vue.js')
  var VueResource=require('vue/vue-resource.js');
</script>

js in

Vue.use(VueResource);
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!