mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-05 21:53:56 +00:00
b11e9c0e51
- [ ] babel-eslint https://github.com/babel/babel-eslint/issues/664 - [x] eslint-config-standard-jsx https://github.com/standard/eslint-config-standard-jsx/issues/32 - [x] eslint-config-standard to be stable release https://github.com/standard/eslint-config-standard/issues/123 - [x] eslint-plugin-html - [x] eslint-plugin-import - [x] eslint-plugin-jest - [x] eslint-plugin-node - [x] eslint-plugin-promise - [x] eslint-plugin-standard https://github.com/standard/eslint-plugin-standard/issues/29 - [x] eslint-plugin-vue https://github.com/vuejs/eslint-plugin-vue/pull/504 - [x] eslint-plugin-react https://github.com/yannickcr/eslint-plugin-react/releases/tag/v7.10.0
80 lines
1.6 KiB
Vue
Executable File
80 lines
1.6 KiB
Vue
Executable File
<template>
|
|
<div>
|
|
<h1>Cookies</h1>
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>Key</th><th>Value</th><th />
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<tr v-for="(value, key) in cookies" :key="key">
|
|
<td>{{ key }}</td>
|
|
<td>{{ value }}</td>
|
|
<td><button @click="removeCookie(key)">Remove</button></td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<h2>Add a new cookie</h2>
|
|
<form @submit.prevent="addCookie">
|
|
<input v-model="newCookie.key" type="text" placeholder="Key" class="key">:
|
|
<input v-model="newCookie.value" type="text" placeholder="Value" class="value">
|
|
<button type="submit">Add</button>
|
|
</form>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
data: () => ({
|
|
newCookie: {
|
|
key: '',
|
|
value: ''
|
|
}
|
|
}),
|
|
computed: {
|
|
cookies() {
|
|
return this.$cookies.cookies
|
|
}
|
|
},
|
|
methods: {
|
|
addCookie() {
|
|
// Make sure the cookie is not empty
|
|
if (!this.newCookie.key || !this.newCookie.value) return
|
|
// Sanitize the key to avoid spaces
|
|
const cookieKey = this.newCookie.key.replace(/\s/g, '-')
|
|
// Add the cookie
|
|
this.$cookies.set(cookieKey, this.newCookie.value)
|
|
// Reset newCookie data
|
|
this.newCookie.key = this.newCookie.value = ''
|
|
},
|
|
removeCookie(key) {
|
|
this.$cookies.remove(key)
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped>
|
|
table {
|
|
text-align: left;
|
|
}
|
|
th, td {
|
|
padding-right: 10px;
|
|
}
|
|
input.key {
|
|
width: 50px;
|
|
}
|
|
input.value {
|
|
width: 100px;
|
|
}
|
|
input, button {
|
|
border: 1px #ddd solid;
|
|
background: white;
|
|
padding: 5px;
|
|
}
|
|
button[type="submit"] {
|
|
margin-left: 5px;
|
|
}
|
|
</style>
|