我的vue练习
DEMO可见地址:https://nidunlove.github.io/myVueTest/dist/index.html
cnpm install vue -g
vue init webpack my-vue-test
? Project name my-vue-test 项目名默认
? Project description A Vue.js project 项目介绍默认
? Author nidun nidunlove@163.com 作者默认
? Vue build standalone (打包方式)
? Install vue-router? Yes 安装vue路由
? Use ESLint to lint your code? No 安装eslint(ESLint 是一个语法规则和代码风格的检查工具,可以用来保证写出语法正确、风格统一的代码。)
? Set up unit tests No (vue单元测试)
? Setup e2e tests with Nightwatch? No (E2E测试)
? Should we run npm install
for you after the project has been created? (recommended) npm
//全选yes 会安装卡顿,试了两次,暂时不安装,原因之后再研究。
cd my-vue-test
cnpm install
cnpm run dev
cnpm run build(注意修改 config/index.js 的assetsPublicPath路径)
打开浏览器访问http://localhost:8080/,开发环境。 打开浏览器访问http://localhost:8080/dist/index.html,线上环境。
参考:https://blog.csdn.net/u014196765/article/details/78022065?locationNum=9&fps=1
-
npm install vuex --save-dev
-
在项目中引用vuex。建一个文件 叫 store.js
登录并新建仓库,编辑readme。
https或ssh上传。
此用ssh命令行 (需要建立ssh key)。
文件夹右键 git bash
cd 文件夹
git init
git status (当前状态)
git add .
git status
git commit -m "myvue" (准备提交和介绍,好像不加介绍会报错)
git reset (需要撤销,此可撤销)
git push origin master
报了很多错,一步步解决了.....
参考:https://www.cnblogs.com/springlight/p/6282152.html
-
打开GitBase
-
切换到项目文件
将本地文件添加到本地缓存库和提交到本地分支,如下命令
-
git add . //将所有的本地文件提交到缓存中;后面的 . 代表所有文件;
-
git commit -m "commit all file" //将所有文件提交到本地库中
提交本地到远程库
-
$ git push -u origin master //第一次提交 添加命令参数 -u 确保关联本地库和远程库
-
$ git push origin master //非第一次提交使用此命令即可
-
cnpm install axios
-
新建axios文件夹和文件,vue中引入
参考:https://github.com/imcvampire/vue-axios
Vue.use(VueAxios, axios);
Vue.axios.get(api).then((response) => {//不知道为何无效 console.log(response.data) })
this.axios.get(api).then((response) => { console.log(response.data) })
this.$http.get(api).then((response) => { console.log(response.data) })
- 或者 参考:
https://segmentfault.com/q/1010000007733865
https://www.cnblogs.com/zhouyangla/p/6753673.html
Vue.prototype.$ajax = axios;
this.$ajax.get(URL)
附:export,import ,export default是什么
https://www.cnblogs.com/xiaotanke/p/7448383.html
- VUE全家桶系列学习
https://blog.csdn.net/zhenghao35791/article/details/67639415
https://blog.csdn.net/qq_33295794/article/details/79024915
- 组件通信
插件引用
树形 父子组件 组件调用 公用组件