vue-hackernews中的异步数据改用vue-resource报错 TypeError:Cannot redefine property:$url
最近学习vue全家桶,改写vue-hackernews中异步数据部分,改用vue-resource,结果报错
主要是在app.js中加入了下面两行代码
import VueResource from 'vue-resource'
Vue.use(VueResource);
结果,npm run dev 正常,页面第一次请求正常。但,当刷新页面时报 Internal Error 500,服务器端报
error during render : /top
TypeError: Cannot redefine property: $url
at Function.defineProperties (<anonymous>)
at plugin (__vue_ssr_bundle__:4089:12)
at Function.Vue.use (/Users/gpd/work/vue-hackernews/node_modules/vue/dist/vue.runtime.common.js:3437:14)
at Object.module.exports.Object.defineProperty.value (__vue_ssr_bundle__:263:45)
at __webpack_require__ (__vue_ssr_bundle__:21:30)
at Object.<anonymous> (__vue_ssr_bundle__:4199:63)
at __webpack_require__ (__vue_ssr_bundle__:21:30)
at __vue_ssr_bundle__:67:18
at Object.<anonymous> (__vue_ssr_bundle__:70:10)
at /Users/gpd/work/vue-hackernews/node_modules/vue-server-renderer/build.js:6346:21
请教大神改如何解?
1 回复
经过搜索发现,是因为vue-resource不再更新,不支持vue-ssr。解决方案是转使用axios或是superagent。