21949410 by 刘远

东川项目前端vue基础框子

1 parent f53b16d4
...@@ -5,7 +5,7 @@ module.exports = { ...@@ -5,7 +5,7 @@ module.exports = {
5 }, 5 },
6 'extends': [ 6 'extends': [
7 'plugin:vue/essential', 7 'plugin:vue/essential',
8 'eslint:recommended' 8 // 'eslint:recommended'
9 ], 9 ],
10 parserOptions: { 10 parserOptions: {
11 parser: 'babel-eslint' 11 parser: 'babel-eslint'
......
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
9 }, 9 },
10 "dependencies": { 10 "dependencies": {
11 "core-js": "^3.6.5", 11 "core-js": "^3.6.5",
12 "echarts": "^4.8.0",
13 "element-ui": "^2.13.2",
12 "vue": "^2.6.11", 14 "vue": "^2.6.11",
13 "vue-router": "^3.2.0", 15 "vue-router": "^3.2.0",
14 "vuex": "^3.4.0" 16 "vuex": "^3.4.0"
......
1 <template> 1 <template>
2 <div id="app"> 2 <div id="app">
3 <div id="nav"> 3 <div id="nav">
4 <router-link to="/">Home</router-link> |
5 <router-link to="/about">About</router-link>
6 </div> 4 </div>
7 <router-view/> 5 <router-view/>
8 </div> 6 </div>
9 </template> 7 </template>
10 8
11 <style> 9 <style>
12 #app {
13 font-family: Avenir, Helvetica, Arial, sans-serif;
14 -webkit-font-smoothing: antialiased;
15 -moz-osx-font-smoothing: grayscale;
16 text-align: center;
17 color: #2c3e50;
18 }
19 10
20 #nav {
21 padding: 30px;
22 }
23
24 #nav a {
25 font-weight: bold;
26 color: #2c3e50;
27 }
28
29 #nav a.router-link-exact-active {
30 color: #42b983;
31 }
32 </style> 11 </style>
......
1 /**
2 * @file commons
3 * Created by He 2020/07/22
4 * @brief 通用方法
5 * @author liuyuan
6 */
7 export default {
8 /**
9 * @brief 依次打印出来, 正式版本要去的掉
10 * @param {...any} args (1,2,3)
11 */
12 log(...args) {
13 args.forEach(val => {
14 console.log(val);
15 });
16 },
17 /**
18 * @param {*} fmt '2020-07-22'
19 * @param {*} date new Date()
20 */
21 dateZhuan(fmt, date) {
22 //日期格式转换
23 var o = {
24 "M+": date.getMonth() + 1, //月份
25 "d+": date.getDate(), //日
26 "h+": date.getHours(), //小时
27 "m+": date.getMinutes(), //分
28 "s+": date.getSeconds(), //秒
29 "q+": Math.floor((date.getMonth() + 3) / 3), //季度
30 "S": date.getMilliseconds() //毫秒
31 };
32 if (/(y+)/.test(fmt))
33 fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
34 for (var k in o)
35 if (new RegExp("(" + k + ")").test(fmt))
36 fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
37 return fmt;
38 },
39 /**
40 * @brief 纯数组去重
41 * @param {*} arr [1, 1, 33, 33, 2]
42 */
43 unique: function (arr) {
44 var newArr = [];
45 var len = arr.length
46 for (var i = 0; i < len; i++) {
47 if (arr.indexOf(arr[i]) == i) {
48 newArr.push(arr[i]);
49 }
50 }
51 return newArr;
52 },
53 /**
54 * @brief:深度拷贝
55 * @param {*} year => obj
56 * */
57 deepClone: function (data) {
58 var type = this.getType(data);
59 var obj;
60 if (type === 'array') {
61 obj = [];
62 } else if (type === 'object') {
63 obj = {};
64 } else {
65 //不再具有下一层次
66 return data;
67 }
68 if (type === 'array') {
69 for (var i = 0, len = data.length; i < len; i++) {
70 obj.push(this.deepClone(data[i]));
71 }
72 } else if (type === 'object') {
73 for (var key in data) {
74 obj[key] = this.deepClone(data[key]);
75 }
76 }
77 return obj;
78 },
79 }
...\ No newline at end of file ...\ No newline at end of file
1 <template>
2 <div class="hello">
3 <h1>{{ msg }}</h1>
4 <p>
5 For a guide and recipes on how to configure / customize this project,<br>
6 check out the
7 <a href="https://cli.vuejs.org" target="_blank" rel="noopener">vue-cli documentation</a>.
8 </p>
9 <h3>Installed CLI Plugins</h3>
10 <ul>
11 <li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-babel" target="_blank" rel="noopener">babel</a></li>
12 <li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-router" target="_blank" rel="noopener">router</a></li>
13 <li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-vuex" target="_blank" rel="noopener">vuex</a></li>
14 <li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-eslint" target="_blank" rel="noopener">eslint</a></li>
15 </ul>
16 <h3>Essential Links</h3>
17 <ul>
18 <li><a href="https://vuejs.org" target="_blank" rel="noopener">Core Docs</a></li>
19 <li><a href="https://forum.vuejs.org" target="_blank" rel="noopener">Forum</a></li>
20 <li><a href="https://chat.vuejs.org" target="_blank" rel="noopener">Community Chat</a></li>
21 <li><a href="https://twitter.com/vuejs" target="_blank" rel="noopener">Twitter</a></li>
22 <li><a href="https://news.vuejs.org" target="_blank" rel="noopener">News</a></li>
23 </ul>
24 <h3>Ecosystem</h3>
25 <ul>
26 <li><a href="https://router.vuejs.org" target="_blank" rel="noopener">vue-router</a></li>
27 <li><a href="https://vuex.vuejs.org" target="_blank" rel="noopener">vuex</a></li>
28 <li><a href="https://github.com/vuejs/vue-devtools#vue-devtools" target="_blank" rel="noopener">vue-devtools</a></li>
29 <li><a href="https://vue-loader.vuejs.org" target="_blank" rel="noopener">vue-loader</a></li>
30 <li><a href="https://github.com/vuejs/awesome-vue" target="_blank" rel="noopener">awesome-vue</a></li>
31 </ul>
32 </div>
33 </template>
34
35 <script>
36 export default {
37 name: 'HelloWorld',
38 props: {
39 msg: String
40 }
41 }
42 </script>
43
44 <!-- Add "scoped" attribute to limit CSS to this component only -->
45 <style scoped>
46 h3 {
47 margin: 40px 0 0;
48 }
49 ul {
50 list-style-type: none;
51 padding: 0;
52 }
53 li {
54 display: inline-block;
55 margin: 0 10px;
56 }
57 a {
58 color: #42b983;
59 }
60 </style>
1 /**
2 * @file commons
3 * Created by He 2020/07/22
4 * @brief 通用配置
5 * @author liuyuan
6 */
7 export default {
8 url: '',
9 }
...\ No newline at end of file ...\ No newline at end of file
...@@ -3,6 +3,19 @@ import App from './App.vue' ...@@ -3,6 +3,19 @@ import App from './App.vue'
3 import router from './router' 3 import router from './router'
4 import store from './store' 4 import store from './store'
5 5
6 import echarts from 'echarts'
7 import config from './config';
8 import commons from './commons/commons';
9
10 import ElementUI from 'element-ui';
11 import 'element-ui/lib/theme-chalk/index.css';
12
13 Vue.use(ElementUI);
14
15
16 Vue.prototype.$echarts = echarts;
17 Vue.prototype.config = config;
18 Vue.prototype.commons = commons;
6 Vue.config.productionTip = false 19 Vue.config.productionTip = false
7 20
8 new Vue({ 21 new Vue({
......
...@@ -4,21 +4,11 @@ import Home from '../views/Home.vue' ...@@ -4,21 +4,11 @@ import Home from '../views/Home.vue'
4 4
5 Vue.use(VueRouter) 5 Vue.use(VueRouter)
6 6
7 const routes = [ 7 const routes = [{
8 { 8 path: '/',
9 path: '/', 9 name: 'Home',
10 name: 'Home', 10 component: Home
11 component: Home 11 }, ]
12 },
13 {
14 path: '/about',
15 name: 'About',
16 // route level code-splitting
17 // this generates a separate chunk (about.[hash].js) for this route
18 // which is lazy-loaded when the route is visited.
19 component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
20 }
21 ]
22 12
23 const router = new VueRouter({ 13 const router = new VueRouter({
24 mode: 'history', 14 mode: 'history',
......
1 export default {
2
3 }
...\ No newline at end of file ...\ No newline at end of file
1 export default {
2 }
...\ No newline at end of file ...\ No newline at end of file
1 import Vue from 'vue' 1 import Vue from 'vue'
2 import Vuex from 'vuex' 2 import Vuex from 'vuex'
3 3
4 Vue.use(Vuex) 4 import demo from './storeModules/demo' // 页面分组例子
5 import actions from './actions'
6 import mutations from './mutations'
7 import state from './state'
5 8
6 export default new Vuex.Store({ 9 Vue.use(Vuex);
7 state: { 10
8 }, 11 export default new Vuex.Store({
9 mutations: { 12 state, //依此加入到store对象中
10 }, 13 mutations,
11 actions: { 14 actions,
12 }, 15 modules: {
13 modules: { 16 demo,
14 } 17 }
15 }) 18 })
...\ No newline at end of file ...\ No newline at end of file
......
1 import constant from './constant'
2
3 export default{
4
5 }
...\ No newline at end of file ...\ No newline at end of file
1 export default {
2 }
...\ No newline at end of file ...\ No newline at end of file
1 /**
2 * @file demo 文件夹名称,命名需和页面一一对应
3 * Created by He 2020/07/22
4 * @brief store 分组 示例
5 * @author liuyuan
6 */
7
8 // 方法名 一定要备注清楚 一定要备注清楚方法实现的内容!!!
9 // const CHANGE_LOAIDNG_TYPE = 'CHANGE_LOAIDNG_TYPE';
10
11 export default {
12 state: {
13 },
14 actions: {
15
16 },
17 mutations: {
18
19 }
20 };
...\ No newline at end of file ...\ No newline at end of file
1 <template>
2 <div class="about">
3 <h1>This is an about page</h1>
4 </div>
5 </template>
1 <template> 1 <template>
2 <div class="home"> 2 <div class="home">
3 <img alt="Vue logo" src="../assets/logo.png"> 3 <el-button type="primary">首页</el-button>
4 <HelloWorld msg="Welcome to Your Vue.js App"/> 4
5 </div> 5 </div>
6 </template> 6 </template>
7 7
8 <script> 8 <script>
9 // @ is an alias to /src 9 export default {
10 import HelloWorld from '@/components/HelloWorld.vue' 10 name: 'Home',
11 components: {},
12 data() {
13 return {
11 14
12 export default { 15 }
13 name: 'Home', 16 }
14 components: { 17 }
15 HelloWorld 18 </script>
16 }
17 }
18 </script>
...\ No newline at end of file ...\ No newline at end of file
......