最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

在Vue中實(shí)現(xiàn)頁(yè)面狀態(tài)保存的各種方法

 更新時(shí)間:2026年01月06日 09:59:38   作者:北辰alk  
作為前端開(kāi)發(fā)者,你一定遇到過(guò)這樣的場(chǎng)景:用戶在一個(gè)復(fù)雜的表單頁(yè)面填寫(xiě)了大量信息,不小心刷新了頁(yè)面或點(diǎn)擊了返回按鈕,所有數(shù)據(jù)都消失了!所以今天我們來(lái)深入探討在 Vue 中實(shí)現(xiàn)頁(yè)面狀態(tài)保存的各種方法,需要的朋友可以參考下

前言:為什么需要保存頁(yè)面狀態(tài)?

作為前端開(kāi)發(fā)者,你一定遇到過(guò)這樣的場(chǎng)景:用戶在一個(gè)復(fù)雜的表單頁(yè)面填寫(xiě)了大量信息,不小心刷新了頁(yè)面或點(diǎn)擊了返回按鈕,所有數(shù)據(jù)都消失了!用戶只能無(wú)奈地重新填寫(xiě)...

保存頁(yè)面狀態(tài)不僅僅是技術(shù)需求,更是提升用戶體驗(yàn)的關(guān)鍵。今天我們來(lái)深入探討在 Vue 中實(shí)現(xiàn)頁(yè)面狀態(tài)保存的各種方法。

一、應(yīng)用場(chǎng)景分析

在我們開(kāi)始技術(shù)實(shí)現(xiàn)之前,先看看哪些場(chǎng)景需要狀態(tài)保存:

  1. 1. 復(fù)雜表單頁(yè)面:用戶填寫(xiě)了一半的表單
  2. 2. 數(shù)據(jù)篩選頁(yè)面:用戶設(shè)置了復(fù)雜的篩選條件
  3. 3. 分頁(yè)列表:用戶瀏覽到第5頁(yè),返回后希望還在第5頁(yè)
  4. 4. 多步驟流程:購(gòu)物車(chē)結(jié)算流程、注冊(cè)流程
  5. 5. 用戶偏好設(shè)置:主題、語(yǔ)言、布局等

二、技術(shù)方案對(duì)比

方案對(duì)比流程圖

少量簡(jiǎn)單數(shù)據(jù)

大量復(fù)雜數(shù)據(jù)

臨時(shí)會(huì)話數(shù)據(jù)

需要服務(wù)端同步

需要保存頁(yè)面狀態(tài)數(shù)據(jù)特點(diǎn)LocalStorageVuex/Pinia + 持久化SessionStorageIndexedDB + 后端API刷新/關(guān)閉后仍存在全局狀態(tài)管理僅當(dāng)前會(huì)話離線可用

三、具體實(shí)現(xiàn)方法

方法1:使用 localStorage 保存簡(jiǎn)單狀態(tài)

適用場(chǎng)景:數(shù)據(jù)量小、結(jié)構(gòu)簡(jiǎn)單的狀態(tài)保存

<template>
  <div>
    <h2>用戶信息表單</h2>
    <form @submit.prevent="handleSubmit">
      <div>
        <label>姓名:</label>
        <input 
          v-model="formData.name" 
          @input="saveToLocalStorage"
          placeholder="請(qǐng)輸入姓名"
        />
      </div>
      <div>
        <label>郵箱:</label>
        <input 
          v-model="formData.email"
          @input="saveToLocalStorage"
          type="email"
          placeholder="請(qǐng)輸入郵箱"
        />
      </div>
      <div>
        <label>備注:</label>
        <textarea 
          v-model="formData.remarks"
          @input="saveToLocalStorage"
          placeholder="請(qǐng)輸入備注信息"
        ></textarea>
      </div>
      <button type="submit">提交</button>
      <button type="button" @click="clearStorage">清除緩存</button>
    </form>
  </div>
</template>

<script>
export default {
  name: 'UserForm',
  data() {
    return {
      formData: {
        name: '',
        email: '',
        remarks: ''
      }
    }
  },
  mounted() {
    // 組件加載時(shí)從 localStorage 恢復(fù)數(shù)據(jù)
    this.restoreFromLocalStorage()
    
    // 監(jiān)聽(tīng)頁(yè)面卸載事件,確保離開(kāi)前保存
    window.addEventListener('beforeunload', this.saveToLocalStorage)
  },
  beforeDestroy() {
    // 清理事件監(jiān)聽(tīng)
    window.removeEventListener('beforeunload', this.saveToLocalStorage)
  },
  methods: {
    // 保存到 localStorage
    saveToLocalStorage() {
      localStorage.setItem('userFormData', JSON.stringify(this.formData))
      console.log('數(shù)據(jù)已保存到本地存儲(chǔ)')
    },
    
    // 從 localStorage 恢復(fù)
    restoreFromLocalStorage() {
      const savedData = localStorage.getItem('userFormData')
      if (savedData) {
        try {
          this.formData = JSON.parse(savedData)
          console.log('數(shù)據(jù)已從本地存儲(chǔ)恢復(fù)')
        } catch (error) {
          console.error('恢復(fù)數(shù)據(jù)失敗:', error)
        }
      }
    },
    
    // 處理表單提交
    handleSubmit() {
      console.log('提交數(shù)據(jù):', this.formData)
      // 提交成功后清除緩存
      localStorage.removeItem('userFormData')
      alert('提交成功!本地緩存已清除。')
    },
    
    // 清除緩存
    clearStorage() {
      localStorage.removeItem('userFormData')
      this.formData = { name: '', email: '', remarks: '' }
      alert('緩存已清除')
    }
  }
}
</script>

方法2:Vuex + 持久化插件方案

適用場(chǎng)景:大型應(yīng)用,需要全局狀態(tài)管理

第一步:安裝必要依賴

npm install vuex-persistedstate

第二步:創(chuàng)建 Vuex Store 并配置持久化

// store/index.js
import Vue from 'vue'
import Vuex from 'vuex'
import createPersistedState from 'vuex-persistedstate'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    userPreferences: {
      theme: 'light',
      language: 'zh-CN',
      fontSize: 14
    },
    shoppingCart: [],
    formStates: {} // 存儲(chǔ)各個(gè)表單的狀態(tài)
  },
  
  mutations: {
    SET_USER_PREFERENCE(state, { key, value }) {
      if (state.userPreferences.hasOwnProperty(key)) {
        state.userPreferences[key] = value
      }
    },
    
    ADD_TO_CART(state, product) {
      const existingItem = state.shoppingCart.find(item => item.id === product.id)
      if (existingItem) {
        existingItem.quantity += product.quantity || 1
      } else {
        state.shoppingCart.push({ ...product, quantity: product.quantity || 1 })
      }
    },
    
    SAVE_FORM_STATE(state, { formId, data }) {
      state.formStates[formId] = data
    },
    
    CLEAR_FORM_STATE(state, formId) {
      if (state.formStates[formId]) {
        delete state.formStates[formId]
      }
    }
  },
  
  actions: {
    saveFormState({ commit }, payload) {
      commit('SAVE_FORM_STATE', payload)
    },
    
    // 清除過(guò)期數(shù)據(jù)(例如24小時(shí)前的數(shù)據(jù))
    clearExpiredStates({ state, commit }) {
      const now = Date.now()
      const expirationTime = 24 * 60 * 60 * 1000 // 24小時(shí)
      
      Object.keys(state.formStates).forEach(formId => {
        const formData = state.formStates[formId]
        if (formData._timestamp && now - formData._timestamp > expirationTime) {
          commit('CLEAR_FORM_STATE', formId)
        }
      })
    }
  },
  
  getters: {
    getFormState: (state) => (formId) => {
      return state.formStates[formId] || null
    },
    
    cartTotalItems: state => {
      return state.shoppingCart.reduce((total, item) => total + item.quantity, 0)
    }
  },
  
  plugins: [
    createPersistedState({
      key: 'vuex-app-state',
      paths: [
        'userPreferences',
        'shoppingCart',
        'formStates'
      ],
      
      // 自定義存儲(chǔ)方式,可以添加加密
      storage: {
        getItem: key => {
          const data = localStorage.getItem(key)
          try {
            // 這里可以添加解密邏輯
            return JSON.parse(data)
          } catch {
            return null
          }
        },
        setItem: (key, value) => {
          // 這里可以添加加密邏輯
          localStorage.setItem(key, JSON.stringify(value))
        },
        removeItem: key => localStorage.removeItem(key)
      },
      
      // 數(shù)據(jù)過(guò)濾,可以排除不需要持久化的數(shù)據(jù)
      reducer: (state) => {
        const { formStates, ...rest } = state
        
        // 過(guò)濾掉時(shí)間戳字段
        const filteredFormStates = {}
        Object.keys(formStates).forEach(key => {
          const { _timestamp, ...formData } = formStates[key]
          filteredFormStates[key] = formData
        })
        
        return {
          ...rest,
          formStates: filteredFormStates
        }
      }
    })
  ]
})

第三步:在組件中使用

<!-- ProductList.vue -->
<template>
  <div class="product-list">
    <h2>商品列表</h2>
    <div class="products">
      <div 
        v-for="product in products" 
        :key="product.id"
        class="product-card"
      >
        <h3>{{ product.name }}</h3>
        <p>價(jià)格: ¥{{ product.price }}</p>
        <button @click="addToCart(product)">
          加入購(gòu)物車(chē)
        </button>
      </div>
    </div>
    
    <!-- 購(gòu)物車(chē)預(yù)覽 -->
    <div class="cart-preview">
      <h3>購(gòu)物車(chē) ({{ cartTotalItems }}件商品)</h3>
      <button @click="goToCart">去結(jié)算</button>
    </div>
  </div>
</template>

<script>
import { mapMutations, mapGetters } from 'vuex'

export default {
  name: 'ProductList',
  
  data() {
    return {
      products: [
        { id: 1, name: '商品A', price: 100 },
        { id: 2, name: '商品B', price: 200 },
        { id: 3, name: '商品C', price: 300 }
      ]
    }
  },
  
  computed: {
    ...mapGetters(['cartTotalItems'])
  },
  
  methods: {
    ...mapMutations(['ADD_TO_CART']),
    
    addToCart(product) {
      this.ADD_TO_CART({
        ...product,
        quantity: 1
      })
      alert('已添加到購(gòu)物車(chē)!刷新頁(yè)面或重新打開(kāi)瀏覽器,購(gòu)物車(chē)數(shù)據(jù)仍然存在。')
    },
    
    goToCart() {
      this.$router.push('/cart')
    }
  }
}
</script>

方法3:使用路由守衛(wèi)保存頁(yè)面狀態(tài)

適用場(chǎng)景:基于路由的頁(yè)面狀態(tài)保存

// router/index.js
import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/form',
    name: 'FormPage',
    component: () => import('../views/FormPage.vue'),
    meta: {
      keepAlive: true, // 需要緩存
      saveState: true  // 需要保存狀態(tài)
    }
  },
  // ...其他路由
]

const router = new VueRouter({
  mode: 'history',
  routes
})

// 頁(yè)面狀態(tài)緩存對(duì)象
const pageStateCache = {}

// 全局前置守衛(wèi)
router.beforeEach((to, from, next) => {
  // 離開(kāi)需要保存狀態(tài)的頁(yè)面時(shí),保存當(dāng)前頁(yè)面狀態(tài)
  if (from.meta.saveState) {
    savePageState(from)
  }
  
  next()
})

// 全局后置守衛(wèi)
router.afterEach((to, from) => {
  // 進(jìn)入需要恢復(fù)狀態(tài)的頁(yè)面時(shí),恢復(fù)頁(yè)面狀態(tài)
  if (to.meta.saveState) {
    restorePageState(to)
  }
})

/**
 * 保存頁(yè)面狀態(tài)
 */
function savePageState(route) {
  const pageKey = getPageKey(route)
  const stateToSave = {
    scrollPosition: window.pageYOffset,
    formData: getFormDataFromPage(),
    timestamp: Date.now()
  }
  
  pageStateCache[pageKey] = stateToSave
  localStorage.setItem(`pageState_${pageKey}`, JSON.stringify(stateToSave))
}

/**
 * 恢復(fù)頁(yè)面狀態(tài)
 */
function restorePageState(route) {
  const pageKey = getPageKey(route)
  let state
  
  // 先從內(nèi)存緩存中獲取
  if (pageStateCache[pageKey]) {
    state = pageStateCache[pageKey]
  } else {
    // 內(nèi)存中沒(méi)有則從localStorage獲取
    const savedState = localStorage.getItem(`pageState_${pageKey}`)
    if (savedState) {
      try {
        state = JSON.parse(savedState)
      } catch (e) {
        console.error('恢復(fù)頁(yè)面狀態(tài)失敗:', e)
      }
    }
  }
  
  if (state) {
    // 恢復(fù)滾動(dòng)位置
    if (state.scrollPosition) {
      setTimeout(() => {
        window.scrollTo(0, state.scrollPosition)
      }, 100)
    }
    
    // 恢復(fù)表單數(shù)據(jù)
    if (state.formData) {
      restoreFormDataToPage(state.formData)
    }
  }
}

/**
 * 生成頁(yè)面唯一標(biāo)識(shí)
 */
function getPageKey(route) {
  return route.path + JSON.stringify(route.query) + JSON.stringify(route.params)
}

export default router

方法4:使用 keep-alive 組件緩存組件實(shí)例

<!-- App.vue -->
<template>
  <div id="app">
    <!-- 使用keep-alive緩存需要保持狀態(tài)的組件 -->
    <keep-alive :include="cachedComponents">
      <router-view v-if="$route.meta.keepAlive" />
    </keep-alive>
    
    <!-- 不需要緩存的組件 -->
    <router-view v-if="!$route.meta.keepAlive" />
  </div>
</template>

<script>
export default {
  name: 'App',
  data() {
    return {
      cachedComponents: ['ProductList', 'UserForm'] // 需要緩存的組件名
    }
  },
  
  // 使用keep-alive的組件會(huì)觸發(fā)這些生命周期
  beforeRouteLeave(to, from, next) {
    // 在離開(kāi)前可以保存一些數(shù)據(jù)
    if (this.saveState) {
      this.saveState()
    }
    next()
  },
  
  activated() {
    // 組件被激活時(shí)調(diào)用
    console.log('組件被激活,可以恢復(fù)狀態(tài)')
    this.restoreState && this.restoreState()
  },
  
  deactivated() {
    // 組件被停用時(shí)調(diào)用
    console.log('組件被停用,可以保存狀態(tài)')
    this.saveState && this.saveState()
  }
}
</script>

四、高級(jí)方案:IndexedDB 存儲(chǔ)大量數(shù)據(jù)

當(dāng)需要存儲(chǔ)大量數(shù)據(jù)或復(fù)雜對(duì)象時(shí),IndexedDB 是更好的選擇。

// utils/db.js
class StateDB {
  constructor(dbName = 'VueAppState', version = 1) {
    this.dbName = dbName
    this.version = version
    this.db = null
  }

  // 打開(kāi)數(shù)據(jù)庫(kù)
  open() {
    return new Promise((resolve, reject) => {
      const request = indexedDB.open(this.dbName, this.version)

      request.onerror = () => reject(request.error)
      request.onsuccess = () => {
        this.db = request.result
        resolve(this.db)
      }

      request.onupgradeneeded = (event) => {
        const db = event.target.result
        
        // 創(chuàng)建對(duì)象存儲(chǔ)空間
        if (!db.objectStoreNames.contains('pageStates')) {
          const store = db.createObjectStore('pageStates', { keyPath: 'id' })
          store.createIndex('timestamp', 'timestamp', { unique: false })
        }
        
        if (!db.objectStoreNames.contains('userData')) {
          db.createObjectStore('userData', { keyPath: 'key' })
        }
      }
    })
  }

  // 保存頁(yè)面狀態(tài)
  async savePageState(pageId, state) {
    if (!this.db) await this.open()
    
    return new Promise((resolve, reject) => {
      const transaction = this.db.transaction(['pageStates'], 'readwrite')
      const store = transaction.objectStore('pageStates')
      
      const record = {
        id: pageId,
        state: state,
        timestamp: Date.now()
      }
      
      const request = store.put(record)
      
      request.onsuccess = () => resolve()
      request.onerror = () => reject(request.error)
    })
  }

  // 獲取頁(yè)面狀態(tài)
  async getPageState(pageId) {
    if (!this.db) await this.open()
    
    return new Promise((resolve, reject) => {
      const transaction = this.db.transaction(['pageStates'], 'readonly')
      const store = transaction.objectStore('pageStates')
      const request = store.get(pageId)
      
      request.onsuccess = () => resolve(request.result?.state)
      request.onerror = () => reject(request.error)
    })
  }

  // 清理過(guò)期數(shù)據(jù)(超過(guò)7天)
  async cleanupOldStates() {
    if (!this.db) await this.open()
    
    const sevenDaysAgo = Date.now() - (7 * 24 * 60 * 60 * 1000)
    
    return new Promise((resolve, reject) => {
      const transaction = this.db.transaction(['pageStates'], 'readwrite')
      const store = transaction.objectStore('pageStates')
      const index = store.index('timestamp')
      const range = IDBKeyRange.upperBound(sevenDaysAgo)
      
      const request = index.openCursor(range)
      
      request.onsuccess = (event) => {
        const cursor = event.target.result
        if (cursor) {
          cursor.delete()
          cursor.continue()
        } else {
          resolve()
        }
      }
      
      request.onerror = () => reject(request.error)
    })
  }
}

// 創(chuàng)建單例實(shí)例
export const stateDB = new StateDB()

// 在 Vue 插件中使用
const StatePersistencePlugin = {
  install(Vue) {
    Vue.prototype.$stateDB = stateDB
    
    // 混入方法到所有組件
    Vue.mixin({
      methods: {
        async saveComponentState(stateKey, data) {
          const componentId = this.$options.name || this.$route?.path || 'unknown'
          const fullKey = `${componentId}_${stateKey}`
          
          try {
            await this.$stateDB.savePageState(fullKey, {
              data,
              savedAt: new Date().toISOString()
            })
            console.log(`狀態(tài)已保存: ${fullKey}`)
          } catch (error) {
            console.error('保存狀態(tài)失敗:', error)
          }
        },
        
        async loadComponentState(stateKey) {
          const componentId = this.$options.name || this.$route?.path || 'unknown'
          const fullKey = `${componentId}_${stateKey}`
          
          try {
            const state = await this.$stateDB.getPageState(fullKey)
            return state?.data || null
          } catch (error) {
            console.error('加載狀態(tài)失敗:', error)
            return null
          }
        }
      }
    })
  }
}

export default StatePersistencePlugin

五、最佳實(shí)踐總結(jié)

1.分層存儲(chǔ)策略

// 根據(jù)數(shù)據(jù)類型選擇不同的存儲(chǔ)方式
const storageStrategy = {
  // 用戶設(shè)置:永久存儲(chǔ)
  userPreferences: localStorage,
  
  // 購(gòu)物車(chē):IndexedDB + 服務(wù)端同步
  shoppingCart: {
    local: indexedDB,
    remote: 'api/cart'
  },
  
  // 表單草稿:sessionStorage(會(huì)話級(jí))
  formDraft: sessionStorage,
  
  // 頁(yè)面滾動(dòng)位置:內(nèi)存緩存
  scrollPosition: 'memory'
}

2.數(shù)據(jù)版本管理

// 添加版本控制,避免數(shù)據(jù)結(jié)構(gòu)變化導(dǎo)致的問(wèn)題
const saveWithVersion = (key, data) => {
  const payload = {
    version: '1.0.0',
    savedAt: new Date().toISOString(),
    data: data
  }
  localStorage.setItem(key, JSON.stringify(payload))
}

const loadWithVersion = (key, currentVersion = '1.0.0') => {
  const saved = localStorage.getItem(key)
  if (!saved) return null
  
  try {
    const { version, data } = JSON.parse(saved)
    
    // 版本遷移邏輯
    if (version !== currentVersion) {
      return migrateData(data, version, currentVersion)
    }
    
    return data
  } catch {
    return null
  }
}

3.自動(dòng)保存與防抖優(yōu)化

import { debounce } from 'lodash'

export default {
  data() {
    return {
      formData: {},
      autoSaveEnabled: true
    }
  },
  
  created() {
    // 使用防抖避免頻繁保存
    this.debouncedSave = debounce(this.saveFormState, 1000)
  },
  
  watch: {
    formData: {
      deep: true,
      handler() {
        if (this.autoSaveEnabled) {
          this.debouncedSave()
        }
      }
    }
  },
  
  methods: {
    saveFormState() {
      // 保存邏輯
    }
  }
}

六、安全注意事項(xiàng)

1. 敏感信息不要保存在客戶端

  • 密碼、token等敏感信息避免本地存儲(chǔ)
  • 必要時(shí)使用加密存儲(chǔ)

2. 數(shù)據(jù)清理機(jī)制

// 定期清理過(guò)期數(shù)據(jù)
setInterval(() => {
  const oneDayAgo = Date.now() - 24 * 60 * 60 * 1000
  Object.keys(localStorage).forEach(key => {
    if (key.startsWith('temp_')) {
      try {
        const item = JSON.parse(localStorage.getItem(key))
        if (item.timestamp && item.timestamp < oneDayAgo) {
          localStorage.removeItem(key)
        }
      } catch {}
    }
  })
}, 60 * 60 * 1000) // 每小時(shí)清理一次

結(jié)語(yǔ)

保存頁(yè)面狀態(tài)是提升 Vue 應(yīng)用用戶體驗(yàn)的關(guān)鍵技術(shù)。根據(jù)不同的場(chǎng)景需求,我們可以選擇:

  • 簡(jiǎn)單場(chǎng)景:使用 localStorage 或 sessionStorage
  • 復(fù)雜應(yīng)用:Vuex/Pinia + 持久化插件
  • 大量數(shù)據(jù):IndexedDB 存儲(chǔ)
  • 組件緩存:keep-alive + 路由守衛(wèi)

記住,最好的方案是分層存儲(chǔ)、按需使用。合理使用狀態(tài)保存,讓你的 Vue 應(yīng)用更加友好和健壯!

以上就是在Vue中實(shí)現(xiàn)頁(yè)面狀態(tài)保存的各種方法的詳細(xì)內(nèi)容,更多關(guān)于Vue保存頁(yè)面狀態(tài)的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

  • 前端使用print.js實(shí)現(xiàn)打印功能(基于vue)

    前端使用print.js實(shí)現(xiàn)打印功能(基于vue)

    最近新接了一個(gè)需求,想要在前端實(shí)現(xiàn)打印功能,下面這篇文章主要給大家介紹了關(guān)于前端使用print.js實(shí)現(xiàn)打印功能(基于vue)的相關(guān)資料,文中通過(guò)實(shí)例代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2023-05-05
  • Vue Router的懶加載路徑的解決方法

    Vue Router的懶加載路徑的解決方法

    這篇文章主要介紹了Vue Router的懶加載路徑的解決方法,非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2018-06-06
  • 簡(jiǎn)單理解vue中el、template、replace元素

    簡(jiǎn)單理解vue中el、template、replace元素

    這篇文章主要幫助大家簡(jiǎn)單理解vue中el、template、replace元素,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2016-10-10
  • vue實(shí)現(xiàn)二級(jí)彈框案例

    vue實(shí)現(xiàn)二級(jí)彈框案例

    這篇文章主要為大家詳細(xì)介紹了vue實(shí)現(xiàn)二級(jí)彈框案例,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-08-08
  • Vue動(dòng)態(tài)表單的應(yīng)用詳解

    Vue動(dòng)態(tài)表單的應(yīng)用詳解

    這篇文章主要為大家詳細(xì)介紹了Vue動(dòng)態(tài)表單的應(yīng)用,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2021-10-10
  • vue實(shí)現(xiàn)購(gòu)物車(chē)的監(jiān)聽(tīng)

    vue實(shí)現(xiàn)購(gòu)物車(chē)的監(jiān)聽(tīng)

    這篇文章主要為大家詳細(xì)介紹了利用vue的監(jiān)聽(tīng)事件實(shí)現(xiàn)一個(gè)簡(jiǎn)單購(gòu)物車(chē),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2020-04-04
  • vue2移動(dòng)端+swiper實(shí)現(xiàn)異形的slide方式

    vue2移動(dòng)端+swiper實(shí)現(xiàn)異形的slide方式

    這篇文章主要介紹了vue2移動(dòng)端+swiper實(shí)現(xiàn)異形的slide方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2024-03-03
  • vue解決跨域問(wèn)題的方法

    vue解決跨域問(wèn)題的方法

    本文主要介紹了前后端分離項(xiàng)目中的跨域問(wèn)題,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2024-12-12
  • vue項(xiàng)目中安裝less依賴的過(guò)程

    vue項(xiàng)目中安裝less依賴的過(guò)程

    這篇文章主要介紹了vue項(xiàng)目中安裝less依賴的過(guò)程,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-08-08
  • vue中data和props的區(qū)別詳解

    vue中data和props的區(qū)別詳解

    這篇文章主要介紹了vue中data和props的區(qū)別,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面跟著小編來(lái)一起學(xué)習(xí)吧
    2024-01-01

最新評(píng)論

汝城县| 防城港市| 晋宁县| 丽江市| 鹰潭市| 绥棱县| 原阳县| 兴仁县| 陆丰市| 普定县| 怀化市| 如皋市| 时尚| 阿城市| 乐东| 长子县| 九龙县| 长乐市| 永济市| 四会市| 乐昌市| 容城县| 泸溪县| 军事| 益阳市| 霍州市| 孝昌县| 黑山县| 梨树县| 泸溪县| 徐水县| 滕州市| 志丹县| 筠连县| 专栏| 莒南县| 庄河市| 辰溪县| 新巴尔虎右旗| 星子县| 乐业县|