fengchuanyu 3 månader sedan
förälder
incheckning
f114ec6af9

+ 3 - 0
12_vuecli/myapp/src/assets/global.css

@@ -0,0 +1,3 @@
+*{
+    color: red;
+}

+ 6 - 0
12_vuecli/myapp/src/assets/golbal.js

@@ -0,0 +1,6 @@
+export function testHandle(){
+    console.log("hello world");
+}
+export function testFun(){
+    console.log("你好世界")
+}

+ 1 - 0
12_vuecli/myapp/src/store/index.js

@@ -4,6 +4,7 @@ import Vuex from 'vuex'
 Vue.use(Vuex)
 
 let user = {
+  namespaced:true,
   state:{
     count:10000
   },

+ 6 - 1
12_vuecli/myapp/src/views/AboutView.vue

@@ -18,7 +18,7 @@
     <button @click="actionHandle">actionHandle</button>
 
     <h1>用户模块:{{$store.state.userModule.count}}</h1>
-    <button @click="$store.commit('userModule/addUser')">用户模块加法操作</button>
+    <button @click="actionFun">用户模块加法操作</button>
   </div>
 </template>
 <script>
@@ -37,6 +37,8 @@ export default {
     },
     actionFun(){
       this.$store.dispatch("actionHandle");
+      // this.$store.commit("addUser");
+      this.$store.commit("userModule/addUser");
     }
   },
   computed:{
@@ -48,3 +50,6 @@ export default {
   }
 }
 </script>
+<style>
+  
+</style>

+ 9 - 1
12_vuecli/myapp/src/views/MyPage.vue

@@ -17,13 +17,16 @@
 
 
 <style scoped>
+    @import url("../assets/global.css");
 /* scoped 标签当前style标签内的样式仅在当前页面生效 */
     h1{
-        color: red;
+        /* color: red; */
     }
 </style>
 
 <script>
+let a = 10;
+import {testHandle,testFun} from '@/assets/golbal.js'
 export default {
     data(){
         return{
@@ -32,6 +35,11 @@ export default {
             userAge:18
         }
     },
+    mounted() {
+        testHandle();
+        testFun();
+        console.log(a);
+    },
     methods: {
         
     },