帮助索引
由于fork后没有issue, 不再fork开发, 请大家勤git pull
可以通过以下代码检验是否安装了yarn
yarn -v
or yarn --version
如果没有安装yarn可以尝试用npm代替, 如果不行可根据以下步骤安装yarn
可以通过Homebrew安装
brew install yarn
可以通过安装程序安装
sudo apt remove cmdtest
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update && sudo apt-get install yarn
yarn install --registry=https://registry.npm.taobao.org
yarn run serve
已配置Ant Design Vue, 可以参考的文档
推荐做法如下:
-
把
vue.config.js
70行的target修改为自己想要的后端,可以是本地(http://127.0.0.1) ,也可以是服务器地址,取决于自己要测的后端地址。注意加上
http://
或者https://
注意url末尾没有斜杠
根据观察,
yarn run serve
以后修改这里的url似乎不会被热加载,所以修改url后应重新yarn run serve
。在最终的后端地址确定之前,本地修改这行地址就好了,不建议将这部分修改放到Git仓库中,否则容易引发冲突(即不add它,具体询问身边大佬)。
-
在
src/api
文件夹下新建文件,可以参考example.js
get方法指定params,post方法指定data
!!后端应获取对应参数,query_params或data!!
-
调用例子在
Login.vue
123行和168行查看具体效果:
yarn run serve
,打开网页,打开调试控制台(Windows Chrome: F12; Mac Chrome: command + option + i),点击“确定”按钮,就会看到如下输出:
实例
// Make a request for a user with a given ID
axios.get('/user?ID=12345')
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
});
// Optionally the request above could also be done as
axios.get('/user', {
params: {
ID: 12345
}
})
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
});
axios.post('/user', {
firstName: 'Fred',
lastName: 'Flintstone'
})
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
});
function getUserAccount() {
return axios.get('/user/12345');
}
function getUserPermissions() {
return axios.get('/user/12345/permissions');
}
axios.all([getUserAccount(), getUserPermissions()])
.then(axios.spread(function (acct, perms) {
// Both requests are now complete
}));