
使用 WebStorm 工具写 Vue,一个项目代码 authorName(val) { const _this = this; if (this.authorName) { this.$http({ url: https://xxxx.org/api/v1/user/${val}, method: 'get' }) .then((res) => { console.log(res); _this.userInfo = res.data.data; _this.loading = false; }) .catch((res) => { console.log('SideSec.vue :', res); }); } } url: https://xxxx.org/api/v1/user/${val},能正确将 val 拼接起来。 另一个项目 created() { console.log(this.$route.path); const _url = 'https://xxxx.org/api/v1${this.$route.path}; this.$http({ url: _url, method: "get" }) 则控制台报错 https://xxxx.org/api/v1$%7Bthis.$route.path%7D 404 (Not Found),字符串没有正确拼接。请问大佬们这是什么原因
1 spaceprogram OP 卧槽,搞定了,原来是要用`而不是' |
2 jessie0717 2018-04-26 09:50:48 +08:00 就你这个排版,我回这一句话已经相当过分了 |