Browse Source

master

master
邓宏 3 years ago
parent
commit
94441c5b62
  1. 32
      src/App.vue
  2. 2
      src/layout/component/appMain.vue
  3. 2
      src/main.js
  4. 4
      src/view/demo.vue
  5. 9
      src/view/home.vue

32
src/App.vue

@ -1,15 +1,3 @@
<script setup>
import { provide } from 'vue'
import {useRouter, useRoute} from 'vue-router'
provide("router", useRouter())
provide("route", useRoute())
</script>
<template>
<router-view />
</template>
<style>
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
@ -20,3 +8,23 @@
height:100%;
}
</style>
<template>
<router-view />
</template>
<script setup>
import { inject, provide } from 'vue'
import {useRouter, useRoute} from 'vue-router'
provide("router", useRouter())
provide("route", useRoute())
var event=inject("event")
window._e=event
function eventDemo(){
setTimeout(()=>{
event.emit("home",323)
eventDemo()
},5000)
}
eventDemo()
</script>

2
src/layout/component/appMain.vue

@ -14,6 +14,6 @@
<script setup>
import { shallowRef } from 'vue'
var cachedViews=shallowRef(['home','demo'])
var cachedViews=shallowRef(['demo'])
var cached=true
</script>

2
src/main.js

@ -4,6 +4,7 @@ import router from './router'
import store from '@/store'
import regComponents from '@/components'
import {defineObj} from 'black-knight/lib/config/custom'
import {provise} from 'black-knight/lib/config/tools'
import ElementPlus from 'element-plus'
import "element-plus/dist/index.css"
console.log(import.meta.env,'--------------import------')
@ -15,6 +16,7 @@ app.use(router)
.use(store)
.use(regComponents)
.use(ElementPlus)
.provide('event',new provise())
.mount('#app')
app.config.globalProperties.foo='===foo====' // 全局配置属性

4
src/view/demo.vue

@ -7,8 +7,8 @@
<script setup>
import { onActivated } from "vue"
console.log("---------demo---------setup---------")
console.log(">>>>>>>>>>>>---------demo---------setup---------")
onActivated(()=>{
console.log("------demo-----------activated-------")
console.log(">>>>>>>>>>>>>------demo-----------activated-------")
})
</script>

9
src/view/home.vue

@ -19,9 +19,16 @@
</div>
</template>
<script setup>
import { onMounted, ref } from 'vue'
import { inject, onMounted, onUnmounted, ref } from 'vue'
import HelloWorld from "@/components/HelloWorld.vue"
import {dInput} from 'black-knight/lib/components'
var event = inject("event")
var value = ref('')
onMounted(()=>{
onUnmounted(event.on("home",data=>{console.log(data,'=======event----------home--1111--')}))
onUnmounted(event.on("home",data=>{console.log(data,'=======event----------home--2222--')}))
})
</script>
Loading…
Cancel
Save