Skip to content

Instantly share code, notes, and snippets.

@onefriendaday
Created November 22, 2018 17:18
Show Gist options
  • Select an option

  • Save onefriendaday/69ebb52f1c4ad953005ec3b93d75481a to your computer and use it in GitHub Desktop.

Select an option

Save onefriendaday/69ebb52f1c4ad953005ec3b93d75481a to your computer and use it in GitHub Desktop.
const Fieldtype = {
mixins: [window.Storyblok.plugin],
template: `<div><input class="uk-width-1-1" v-model="model.number" /></div>`,
methods: {
initWith() {
return {
plugin: 'number-plugin',
number: '0'
}
},
pluginCreated() {
console.log('plugin:created')
}
},
watch: {
'model': {
handler: function (value) {
value.number = parseInt(value.number, 10)
if (isNaN(value.number)) {
value.number = 0
}
this.$emit('changed-model', value);
},
deep: true
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment