项目中的个性化设置页中,设置登录页的字体颜色,需要用户自己设置其颜色
<div id="app">
<v-app id="inspire">
<v-container>
<v-row>
<v-col
class="d-flex justify-center"
>
<v-color-picker v-model="color"></v-color-picker>
</v-col>
<v-col
cols="12"
md="4"
>
<v-sheet
dark
class="pa-4"
>
<pre>{{ showColor }}</pre>
</v-sheet>
</v-col>
</v-row>
</v-container>
</v-app>
</div>
new Vue({
el: '#app',
vuetify: new Vuetify(),
data: () => ({
type: 'hex',
hex: '#FF00FF',
}),
computed: {
color: {
get () {
return this[this.type]
},
set (v) {
console.log(v)
this[this.type] = v
},
},
showColor () {
if (typeof this.color === 'string') return this.color
return JSON.stringify(Object.keys(this.color).reduce((color, key) => {
color[key] = Number(this.color[key].toFixed(2))
return color
}, {}), null, 2)
},
},
})