父组件向子组件通信
-
+
{{ count }}
@@ -14,16 +20,14 @@
data: function () {
return {
message: "从父组件中传递进来的值",
- count: 0
+ count: 0,
+ arr: [1, 2, 3, 4, 5]
}
},
components: {
child,
},
methods: {
- getChildrenData: function (data) {
- console.log(data);
- },
increased: function () {
return this.count += 1
},
diff --git a/src/components/features/echarts/echarts.vue b/src/components/features/echarts/echarts.vue
new file mode 100755
index 0000000000000000000000000000000000000000..ea6ef821aaa3a11a34982be2b4783bc2023f73a4
--- /dev/null
+++ b/src/components/features/echarts/echarts.vue
@@ -0,0 +1,76 @@
+
+
+
图标的使用
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/components/vue-router/404.vue b/src/components/vue-router/404.vue
new file mode 100755
index 0000000000000000000000000000000000000000..7ade3661c94cb8efaa051d0bc7e647f0696df726
--- /dev/null
+++ b/src/components/vue-router/404.vue
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/components/vue-router/Profile.vue b/src/components/vue-router/Profile.vue
new file mode 100755
index 0000000000000000000000000000000000000000..2bdea6207a74565dd8a334a054c908e8ca131251
--- /dev/null
+++ b/src/components/vue-router/Profile.vue
@@ -0,0 +1,11 @@
+
+ profile,这是一个嵌套路由
+
+
+
+
+
\ No newline at end of file
diff --git a/src/components/vue-router/Router1.vue b/src/components/vue-router/Router1.vue
new file mode 100755
index 0000000000000000000000000000000000000000..43e6431b2f22f61fc2c4a91069878aa98dca23c0
--- /dev/null
+++ b/src/components/vue-router/Router1.vue
@@ -0,0 +1,80 @@
+
+
+
+
通过router-link传递参数
+
+ 传递一个参数,通过router-link
+
+
+
+
+
+ 价格表
+ 操作按钮
+
+
+
+
+
+
+
+
{{ item.title }}
+
{{ item.sale }}
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/components/vue-router/Show.vue b/src/components/vue-router/Show.vue
new file mode 100755
index 0000000000000000000000000000000000000000..50250e2e28b13c0c6bfddef1b5a984ac90aa00ba
--- /dev/null
+++ b/src/components/vue-router/Show.vue
@@ -0,0 +1,41 @@
+
+
+
获取传递进来的参数
+
+ params: {{ $route.params.id }}
+
+
+
+ 拥有相同的父路由
+
+
+
嵌套路由的使用
+ 跳转到子路由
+
+ 跳转
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/components/vuex/ProductList.vue b/src/components/vuex/ProductList.vue
new file mode 100755
index 0000000000000000000000000000000000000000..34fcf158e6ac9e73e0b353f56ff05f12f4c4059f
--- /dev/null
+++ b/src/components/vuex/ProductList.vue
@@ -0,0 +1,40 @@
+
+
+
+ -
+ {{ product.title }} - {{ product.prict }}
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/components/vuex/Shopping.vue b/src/components/vuex/Shopping.vue
new file mode 100755
index 0000000000000000000000000000000000000000..a28f2ffdad7847162866b2c5f623ef3d55214fe0
--- /dev/null
+++ b/src/components/vuex/Shopping.vue
@@ -0,0 +1,29 @@
+
+
+
购物车实例
+
账号: {{ email }}
+
+
产品
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/components/vuex/ShoppingCart.vue b/src/components/vuex/ShoppingCart.vue
new file mode 100755
index 0000000000000000000000000000000000000000..fe67f36045c1cca135f03afa14aa5e2ecce2a3b7
--- /dev/null
+++ b/src/components/vuex/ShoppingCart.vue
@@ -0,0 +1,44 @@
+
+
+
清单
+
+ 请添加商品到购物车
+
+
+ -
+ {{ product.title }} - {{ product.price }} x {{ product.quantity }}
+
+
+
合计: {{ total }}
+
+
+
+
提交 {{ checkoutStatus }}
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main.js b/src/main.js
index af21abced24e6115f5644321fadd841540b59f08..b30c6084cba9db1e4591fcbba5382c659d05a074 100755
--- a/src/main.js
+++ b/src/main.js
@@ -2,10 +2,13 @@ import Vue from 'vue';
import VueRouter from 'vue-router';
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
-import store from './store';
+import store from './store/index';
import App from './App.vue';
import routes from './router';
+import './assets/style/common.styl';
+import './assets/style/element-override.styl';
+
Vue.config.productionTip = false
Vue.use(ElementUI)
Vue.use(VueRouter)
diff --git a/src/router/index.js b/src/router/index.js
index 31dcd6850b6ce94782ce52bb7c45809866a5aeda..cbc4b5966c3418357c7a0a2e08d9f6b41ffda5aa 100755
--- a/src/router/index.js
+++ b/src/router/index.js
@@ -1,15 +1,57 @@
+import Home from '../components/Home.vue';
import CustomTable from '../components/element-component/CustomTable.vue';
-import exam_parent from '../components/example/parent-child/parent.vue';
+import ExamParent from '../components/example/parent-child/parent.vue';
+import Echarts from '../components/features/echarts/echarts.vue';
+import CustomDrawer from '../components/features/drawer/Example.vue';
+import Router1 from '../components/vue-router/Router1.vue';
+import Show from '../components/vue-router/Show.vue';
+import PageNotFound from '../components/vue-router/404.vue';
+import Profile from '../components/vue-router/Profile.vue';
+import Shopping from '../components/vuex/Shopping.vue';
const routes = [
{
path: '/',
- component: CustomTable
+ component: Home
},
{
path: '/parent',
- component: exam_parent
+ component: ExamParent
+ },
+ {
+ path: '/table',
+ component: CustomTable
+ },
+ {
+ path: '/drawer',
+ component: CustomDrawer
+ },
+ {
+ path: '/echarts',
+ component: Echarts
+ },
+ {
+ path: '/routes',
+ component: Router1,
+ },
+ {
+ path: '/show/:id',
+ component: Show,
+ name: 'show',
+ children: [
+ { path: 'profile', component: Profile },
+ { path: '/profile', component: Profile }
+ ]
+ },
+ {
+ path: '/shopping-card',
+ component: Shopping,
+ name: 'shopping',
+ },
+ {
+ path: '*',
+ component: PageNotFound
}
]
diff --git a/src/store.js b/src/store.js
deleted file mode 100755
index 705be7b674d85a4022469badfec879173338534a..0000000000000000000000000000000000000000
--- a/src/store.js
+++ /dev/null
@@ -1,14 +0,0 @@
-import Vue from 'vue';
-import Vuex from 'vuex';
-
-Vue.use(Vuex);
-
-export default new Vuex.Store({
- state: {
- count: 0
- },
- mutations: {
- addCount: state => state.count ++
- }
-})
-
diff --git a/src/store/index.js b/src/store/index.js
new file mode 100755
index 0000000000000000000000000000000000000000..a1759b070da03b3e659edbc106962b4d5780f7d3
--- /dev/null
+++ b/src/store/index.js
@@ -0,0 +1,20 @@
+import Vue from 'vue'
+import Vuex from 'vuex'
+import homeIndex from './modules/homeIndex'
+import cart from './modules/cart'
+import products from './modules/products'
+
+Vue.use(Vuex)
+
+export default new Vuex.Store({
+ state: {
+ userInfo: {
+ email: "zongwu@gmail.com"
+ }
+ },
+ modules: {
+ homeIndex,
+ cart,
+ products
+ },
+})
\ No newline at end of file
diff --git a/src/store/modules/cart.js b/src/store/modules/cart.js
new file mode 100755
index 0000000000000000000000000000000000000000..8d597bc3e24f5bf5f5e4c3aba3e080c82e5d766e
--- /dev/null
+++ b/src/store/modules/cart.js
@@ -0,0 +1,25 @@
+import shop from '../../common/api/shop';
+import { CART, PRODUCTS } from '../mutation-types';
+
+const state = {
+ items: [],
+ checkoutStatus: null
+}
+
+const getters = {
+ // cartProducts: (state, getters, rootState) {
+ // return state.items.map(({}) => {})
+ // }
+}
+
+const actions = {}
+
+const mutations = {}
+
+export default {
+ namespaced: true,
+ state,
+ getters,
+ actions,
+ mutations
+}
\ No newline at end of file
diff --git a/src/store/modules/homeIndex.js b/src/store/modules/homeIndex.js
new file mode 100755
index 0000000000000000000000000000000000000000..a2602a0cbe30bcfb02ba54da333b21e9d289b065
--- /dev/null
+++ b/src/store/modules/homeIndex.js
@@ -0,0 +1,18 @@
+const state = {
+ navList: [
+ {id: 1, url: '/parent', label: '组件通信' },
+ {id: 2, url: '/table', label: 'Element Table' },
+ {id: 3, url: '/drawer', label: '侧边弹出层' },
+ {id: 4, url: '/echarts', label: '图表' }
+ ]
+}
+
+const mutations = {}
+
+const actions = {}
+
+export default {
+ state,
+ mutations,
+ actions,
+}
diff --git a/src/store/modules/products.js b/src/store/modules/products.js
new file mode 100755
index 0000000000000000000000000000000000000000..e651fb73f6906aec60c8cce7b305684d82d76f7c
--- /dev/null
+++ b/src/store/modules/products.js
@@ -0,0 +1,28 @@
+import shop from '../../common/api/shop';
+import { PRODUCTS } from '../mutation-types';
+const state = {
+ all: []
+}
+
+const getters = {}
+
+const actions = {
+ getAllProducts ({commit}) {
+ shop.getProducts(products => commit(PRODUCTS.SET_PRODUCTS, products) )
+ }
+}
+
+const mutations = {
+ [PRODUCTS.SET_PRODUCTS] (state, products) {
+ state.all = products
+ }
+}
+
+
+export default {
+ namespaced: true,
+ state,
+ getters,
+ actions,
+ mutations
+}
diff --git a/src/store/mutation-types.js b/src/store/mutation-types.js
new file mode 100755
index 0000000000000000000000000000000000000000..24a4ab934c16e4544e349f5c687a1b26dd3c5817
--- /dev/null
+++ b/src/store/mutation-types.js
@@ -0,0 +1,8 @@
+export const CART = {
+ PUSH_RPODUCT_TO_CART: 'pushProductToCart',
+ SETCHECKOUTSTATUS: 'setCheckoutStatus',
+}
+
+export const PRODUCTS = {
+ SET_PRODUCTS: 'setProducts',
+}
\ No newline at end of file
diff --git a/yarn.lock b/yarn.lock
index 3ba37a257029394e6c349b9d5f14a6575554ca1f..496ffb243663a8bea71e78e6c506ef1f6c9a9408 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2357,6 +2357,11 @@ css-loader@^1.0.1:
postcss-value-parser "^3.3.0"
source-list-map "^2.0.0"
+css-parse@1.7.x:
+ version "1.7.0"
+ resolved "https://registry.yarnpkg.com/css-parse/-/css-parse-1.7.0.tgz#321f6cf73782a6ff751111390fc05e2c657d8c9b"
+ integrity sha1-Mh9s9zeCpv91ERE5D8BeLGV9jJs=
+
css-select-base-adapter@^0.1.1:
version "0.1.1"
resolved "http://registry.npm.taobao.org/css-select-base-adapter/download/css-select-base-adapter-0.1.1.tgz#3b2ff4972cc362ab88561507a95408a1432135d7"
@@ -2529,6 +2534,13 @@ de-indent@^1.0.2:
resolved "http://registry.npm.taobao.org/de-indent/download/de-indent-1.0.2.tgz#b2038e846dc33baa5796128d0804b455b8c1e21d"
integrity sha1-sgOOhG3DO6pXlhKNCAS0VbjB4h0=
+debug@*, debug@^4.0.1, debug@^4.1.0, debug@^4.1.1:
+ version "4.1.1"
+ resolved "http://registry.npm.taobao.org/debug/download/debug-4.1.1.tgz#3b72260255109c6b589cee050f1d516139664791"
+ integrity sha1-O3ImAlUQnGtYnO4FDx1RYTlmR5E=
+ dependencies:
+ ms "^2.1.1"
+
debug@2.6.9, debug@^2.1.2, debug@^2.2.0, debug@^2.3.3:
version "2.6.9"
resolved "http://registry.npm.taobao.org/debug/download/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f"
@@ -2543,13 +2555,6 @@ debug@^3.1.0, debug@^3.2.5, debug@^3.2.6:
dependencies:
ms "^2.1.1"
-debug@^4.0.1, debug@^4.1.0, debug@^4.1.1:
- version "4.1.1"
- resolved "http://registry.npm.taobao.org/debug/download/debug-4.1.1.tgz#3b72260255109c6b589cee050f1d516139664791"
- integrity sha1-O3ImAlUQnGtYnO4FDx1RYTlmR5E=
- dependencies:
- ms "^2.1.1"
-
decamelize@^2.0.0:
version "2.0.0"
resolved "http://registry.npm.taobao.org/decamelize/download/decamelize-2.0.0.tgz#656d7bbc8094c4c788ea53c5840908c9c7d063c7"
@@ -2832,6 +2837,13 @@ ecc-jsbn@~0.1.1:
jsbn "~0.1.0"
safer-buffer "^2.1.0"
+echarts@^4.2.1:
+ version "4.2.1"
+ resolved "https://registry.yarnpkg.com/echarts/-/echarts-4.2.1.tgz#9a8ea3b03354f86f824d97625c334cf16965ef03"
+ integrity sha512-pw4xScRPsLegD/cqEcoXRKeA2SD4+s+Kyo0Na166NamOWhzNl2yI5RZ2rE97tBlAopNmhyMeBVpAeD5qb+ee1A==
+ dependencies:
+ zrender "4.0.7"
+
ee-first@1.1.1:
version "1.1.1"
resolved "http://registry.npm.taobao.org/ee-first/download/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d"
@@ -3701,6 +3713,18 @@ glob-to-regexp@^0.3.0:
resolved "http://registry.npm.taobao.org/glob-to-regexp/download/glob-to-regexp-0.3.0.tgz#8c5a1494d2066c570cc3bfe4496175acc4d502ab"
integrity sha1-jFoUlNIGbFcMw7/kSWF1rMTVAqs=
+glob@7.0.x:
+ version "7.0.6"
+ resolved "https://registry.yarnpkg.com/glob/-/glob-7.0.6.tgz#211bafaf49e525b8cd93260d14ab136152b3f57a"
+ integrity sha1-IRuvr0nlJbjNkyYNFKsTYVKz9Xo=
+ dependencies:
+ fs.realpath "^1.0.0"
+ inflight "^1.0.4"
+ inherits "2"
+ minimatch "^3.0.2"
+ once "^1.3.0"
+ path-is-absolute "^1.0.0"
+
glob@^5.0.15:
version "5.0.15"
resolved "https://registry.yarnpkg.com/glob/-/glob-5.0.15.tgz#1bc936b9e02f4a603fcc222ecf7633d30b8b93b1"
@@ -4782,6 +4806,11 @@ locate-path@^3.0.0:
p-locate "^3.0.0"
path-exists "^3.0.0"
+lodash.clonedeep@^4.5.0:
+ version "4.5.0"
+ resolved "https://registry.yarnpkg.com/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz#e23f3f9c4f8fbdde872529c1071857a086e5ccef"
+ integrity sha1-4j8/nE+Pvd6HJSnBBxhXoIblzO8=
+
lodash.defaultsdeep@^4.6.0:
version "4.6.0"
resolved "http://registry.npm.taobao.org/lodash.defaultsdeep/download/lodash.defaultsdeep-4.6.0.tgz#bec1024f85b1bd96cbea405b23c14ad6443a6f81"
@@ -6570,6 +6599,11 @@ requires-port@^1.0.0:
resolved "http://registry.npm.taobao.org/requires-port/download/requires-port-1.0.0.tgz#925d2601d39ac485e091cf0da5c6e694dc3dcaff"
integrity sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8=
+resize-detector@^0.1.9:
+ version "0.1.10"
+ resolved "https://registry.yarnpkg.com/resize-detector/-/resize-detector-0.1.10.tgz#1da3f961aa5f914ccbcfd3752d52fd45beeb692c"
+ integrity sha512-iLcXC8A6Fb0DfA+TRiywrK/0A22bFqkhntjMJMEzXDA4XkcEkfwpNbv7W8iewUiD0xYIaeiXOfiEehTqGKsUFw==
+
resize-observer-polyfill@^1.5.0:
version "1.5.1"
resolved "https://registry.yarnpkg.com/resize-observer-polyfill/-/resize-observer-polyfill-1.5.1.tgz#0e9020dd3d21024458d4ebd27e23e40269810464"
@@ -6697,6 +6731,11 @@ safe-regex@^1.1.0:
resolved "http://registry.npm.taobao.org/safer-buffer/download/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a"
integrity sha1-RPoWGwGHuVSd2Eu5GAL5vYOFzWo=
+sax@0.5.x:
+ version "0.5.8"
+ resolved "https://registry.yarnpkg.com/sax/-/sax-0.5.8.tgz#d472db228eb331c2506b0e8c15524adb939d12c1"
+ integrity sha1-1HLbIo6zMcJQaw6MFVJK25OdEsE=
+
sax@^1.2.4, sax@~1.2.4:
version "1.2.4"
resolved "http://registry.npm.taobao.org/sax/download/sax-1.2.4.tgz#2816234e2378bddc4e5354fab5caa895df7100d9"
@@ -6965,6 +7004,13 @@ source-map-url@^0.4.0:
resolved "http://registry.npm.taobao.org/source-map-url/download/source-map-url-0.4.0.tgz#3e935d7ddd73631b97659956d55128e87b5084a3"
integrity sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM=
+source-map@0.1.x:
+ version "0.1.43"
+ resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.1.43.tgz#c24bc146ca517c1471f5dacbe2571b2b7f9e3346"
+ integrity sha1-wkvBRspRfBRx9drL4lcbK3+eM0Y=
+ dependencies:
+ amdefine ">=0.0.4"
+
source-map@^0.4.2:
version "0.4.4"
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.4.4.tgz#eba4f5da9c0dc999de68032d8b4f76173652036b"
@@ -7240,6 +7286,27 @@ stylehacks@^4.0.0:
postcss "^7.0.0"
postcss-selector-parser "^3.0.0"
+stylus-loader@^3.0.2:
+ version "3.0.2"
+ resolved "https://registry.yarnpkg.com/stylus-loader/-/stylus-loader-3.0.2.tgz#27a706420b05a38e038e7cacb153578d450513c6"
+ integrity sha512-+VomPdZ6a0razP+zinir61yZgpw2NfljeSsdUF5kJuEzlo3khXhY19Fn6l8QQz1GRJGtMCo8nG5C04ePyV7SUA==
+ dependencies:
+ loader-utils "^1.0.2"
+ lodash.clonedeep "^4.5.0"
+ when "~3.6.x"
+
+stylus@^0.54.5:
+ version "0.54.5"
+ resolved "https://registry.yarnpkg.com/stylus/-/stylus-0.54.5.tgz#42b9560931ca7090ce8515a798ba9e6aa3d6dc79"
+ integrity sha1-QrlWCTHKcJDOhRWnmLqeaqPW3Hk=
+ dependencies:
+ css-parse "1.7.x"
+ debug "*"
+ glob "7.0.x"
+ mkdirp "0.5.x"
+ sax "0.5.x"
+ source-map "0.1.x"
+
supports-color@^2.0.0:
version "2.0.0"
resolved "http://registry.npm.taobao.org/supports-color/download/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7"
@@ -7742,6 +7809,14 @@ vue-drawer@^0.1.0:
vue "^1.0.26"
vue-touch "^1.1.0"
+vue-echarts@^4.0.1:
+ version "4.0.1"
+ resolved "https://registry.yarnpkg.com/vue-echarts/-/vue-echarts-4.0.1.tgz#3d3a14f53119701bba09545a68b17cf0689cad29"
+ integrity sha512-JgvIcr/btz4bAkafVm0aLyfkAdhGf2T8VIdESd2264Mlr5w0dZ0IOG3BJCvtznIlBJMiwQXAztc27Y3KGKdF5Q==
+ dependencies:
+ lodash "^4.17.11"
+ resize-detector "^0.1.9"
+
vue-eslint-parser@^2.0.3:
version "2.0.3"
resolved "http://registry.npm.taobao.org/vue-eslint-parser/download/vue-eslint-parser-2.0.3.tgz#c268c96c6d94cfe3d938a5f7593959b0ca3360d1"
@@ -7994,6 +8069,11 @@ websocket-extensions@>=0.1.1:
resolved "http://registry.npm.taobao.org/websocket-extensions/download/websocket-extensions-0.1.3.tgz#5d2ff22977003ec687a4b87073dfbbac146ccf29"
integrity sha1-XS/yKXcAPsaHpLhwc9+7rBRszyk=
+when@~3.6.x:
+ version "3.6.4"
+ resolved "https://registry.yarnpkg.com/when/-/when-3.6.4.tgz#473b517ec159e2b85005497a13983f095412e34e"
+ integrity sha1-RztRfsFZ4rhQBUl6E5g/CVQS404=
+
which-module@^2.0.0:
version "2.0.0"
resolved "http://registry.npm.taobao.org/which-module/download/which-module-2.0.0.tgz#d9ef07dce77b9902b8a3a8fa4b31c3e3f7e6e87a"
@@ -8118,3 +8198,8 @@ yorkie@^2.0.0:
is-ci "^1.0.10"
normalize-path "^1.0.0"
strip-indent "^2.0.0"
+
+zrender@4.0.7:
+ version "4.0.7"
+ resolved "https://registry.yarnpkg.com/zrender/-/zrender-4.0.7.tgz#15ae960822f5efed410995d37e5107fe3de10e6d"
+ integrity sha512-TNloHe0ums6zxbHfnaCryM61J4IWDajZwNq6dHk9vfWhhysO/OeFvvR0drBs/nbXha2YxSzfQj2FiCd6RVBe+Q==