Skip to content

Commit ff7e502

Browse files
committed
修复资源引入的问题
1 parent ace8077 commit ff7e502

File tree

3 files changed

+24
-24
lines changed

3 files changed

+24
-24
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ pnpm-debug.log*
88
lerna-debug.log*
99

1010
node_modules
11-
# dist
11+
dist
1212
dist-ssr
1313
*.local
1414

src/components/chartMap/index.vue

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { reactive } from 'vue'
33
import axios from 'axios'
44
import WChart from '@comp/chart/index.vue'
55
import 'echarts/extension/bmap/bmap'
6+
import xianJson from '@/assets/xian.json'
67
78
defineOptions({
89
name: 'ChartMap'
@@ -39,26 +40,18 @@ const option = {
3940
}
4041
4142
const 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

src/components/header/index.vue

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<script setup lang="ts">
2-
import { computed, ref, defineProps } from 'vue'
2+
import { computed, defineProps, onMounted, ref } from 'vue'
33
import { useUserStore } from '@store/user'
4+
import logoImg from '@/assets/logo.png'
45
56
const userStore = useUserStore()
67
// 获取state使用computed或者使用storeToRefs,直接使用不具备响应式(拿到的永远是初次的值)
@@ -13,7 +14,7 @@ defineOptions({
1314
const 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>

0 commit comments

Comments
 (0)