Vue Plugin: vuejs-storage

發表於
分類於 專案

This article is automatically translated by LLM, so the translation may be inaccurate or incomplete. If you find any mistake, please let me know.
You can find the original article here .

This is a plugin for Vue that binds localStorage/sessionStorage, and can also be used with Vuex.

GitHub: https://github.com/maple3142/vuejs-storage

Simple TodoList example: maple3142/TodoList

Installation

Install: npm install vuejs-storage For browsers, you can use the CDN: https://unpkg.com/vuejs-storage

Code

<script src="https://unpkg.com/vue/dist/vue.min.js"></script>
<script src="https://unpkg.com/vuejs-storage/dist/vuejs-storage.min.js"></script>
<div id="vjss">
	<input type="text" v-model="text">
</div>
Vue.use(vuejsStorage) //安裝插件
new Vue({
	el: '#vjss',
	data: {
		text: ''
	},
	storage: {
		//使用storage選項
		namespace: 'vuejs-storage-example',
		//指定要存哪些變數
		keys: ['text']
	}
})

For more detailed tutorials, you can visit https://github.com/maple3142/vuejs-storage