File tree Expand file tree Collapse file tree 3 files changed +24
-24
lines changed Expand file tree Collapse file tree 3 files changed +24
-24
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ pnpm-debug.log*
88lerna-debug.log *
99
1010node_modules
11- # dist
11+ dist
1212dist-ssr
1313* .local
1414
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import { reactive } from 'vue'
33import axios from ' axios'
44import WChart from ' @comp/chart/index.vue'
55import ' echarts/extension/bmap/bmap'
6+ import xianJson from ' @/assets/xian.json'
67
78defineOptions ({
89 name: ' ChartMap'
@@ -39,26 +40,18 @@ const option = {
3940}
4041
4142const initBefore = () => {
42- return new Promise ((resolve , reject ) => {
43- axios .get (' src/assets/xian.json' ).then (
44- (resp ) => {
45- const { data } = resp
46- // 处理数据
47- const arr = []
48- for (const item of data .features ) {
49- const positions = item .geometry .coordinates [0 ][0 ]
50- for (const temp of positions ) {
51- const position = temp .concat (Math .random () * 1000 + 200 )
52- arr .push (position )
53- }
54- }
55- option .series [0 ].data = arr
56- resolve (option )
57- },
58- (error ) => {
59- reject (error )
43+ return new Promise ((resolve ) => {
44+ // 处理数据
45+ const arr = []
46+ for (const item of xianJson .features ) {
47+ const positions = item .geometry .coordinates [0 ][0 ]
48+ for (const temp of positions ) {
49+ const position = temp .concat (Math .random () * 1000 + 200 )
50+ arr .push (position )
6051 }
61- )
52+ }
53+ option .series [0 ].data = arr
54+ resolve (option )
6255 })
6356}
6457
Original file line number Diff line number Diff line change 11<script setup lang="ts">
2- import { computed , ref , defineProps } from ' vue'
2+ import { computed , defineProps , onMounted , ref } from ' vue'
33import { useUserStore } from ' @store/user'
4+ import logoImg from ' @/assets/logo.png'
45
56const userStore = useUserStore ()
67// 获取state使用computed或者使用storeToRefs,直接使用不具备响应式(拿到的永远是初次的值)
@@ -13,7 +14,7 @@ defineOptions({
1314const props = defineProps ({
1415 logo: {
1516 type: String , // 参数类型
16- default: ' /src/assets/logo.png ' , // 默认值
17+ default: logoImg , // 默认值
1718 required: false // 是否必须传递
1819 },
1920 title: {
@@ -22,13 +23,19 @@ const props = defineProps({
2223 required: true // 是否必须传递
2324 }
2425})
25- const logo = ref (props .logo )
26+
27+ const logoDom = ref ()
28+ // 声明周期函数,自动执行初始化
29+ onMounted (() => {
30+ const dom = logoDom .value
31+ dom .src = props .logo
32+ })
2633 </script >
2734
2835<template >
2936 <div class =" w-header" >
3037 <div class =" logo" >
31- <img :src = " logo " alt =" logo" width =" 120" />
38+ <img ref = " logoDom " alt =" logo" width =" 120" />
3239 </div >
3340 <div class =" title-wrapper" >
3441 <dv-decoration7 >
You can’t perform that action at this time.
0 commit comments