设置初始宽度
This commit is contained in:
@@ -3,7 +3,7 @@ import { ref, computed } from 'vue'
|
|||||||
export const useGlobalStore = defineStore('global', () => {
|
export const useGlobalStore = defineStore('global', () => {
|
||||||
const state = ref({
|
const state = ref({
|
||||||
loading: false,// 全局loading
|
loading: false,// 全局loading
|
||||||
windowWidth: window.innerWidth,// 页面宽度
|
windowWidth: 1920,// 页面宽度
|
||||||
})
|
})
|
||||||
|
|
||||||
const setLoading = (v: boolean) => { state.value.loading = v }
|
const setLoading = (v: boolean) => { state.value.loading = v }
|
||||||
@@ -13,6 +13,8 @@ export const useGlobalStore = defineStore('global', () => {
|
|||||||
setLoading,
|
setLoading,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
window.addEventListener('resize', () => {
|
function setWindowWidth() {
|
||||||
useGlobalStore().state.windowWidth = window.innerWidth
|
return useGlobalStore().state.windowWidth = window.innerWidth
|
||||||
})
|
}
|
||||||
|
window.addEventListener('resize', setWindowWidth)
|
||||||
|
window.addEventListener('load', setWindowWidth)
|
||||||
Reference in New Issue
Block a user