Vue.directive('rainbow', {
bind(el, binding, vnode) {
el.style.color =
'#' +
Math.random()
.toString(16)
.slice(2, 8)
},
})
Vue.filter('snippet', function(value) {
return value.slice(0, 100) + '...'
})
filterBlog() {
return this.blogs.filter((blog) => {
return blog.title.match(this.search)
})
},
created() {
this.fetchData()
},
methos() {
fetchData() {
axios.get('/posts/' + this.id + '/.json'then((res) => {
this.blog = res.data
// 若旧博客未选择类型,点击编辑后把types置为空数组
if (this.blog.types === undefined) {
this.blog.types = []
}
})
},
}