javascript - Use Mixin in template with Nuxt
问题描述
I am trying to call the mixin function within the template. Vue documentation says mixin and the component are merged but i can't call the function.
getImage is not a function
Mixin
export default {
data() {
return {
l: 2,
output: 'webp'
}
},
methods: {
getImage() {
return 'www.example.url'
}
}
}
Component
<template>
<v-img :src="getImage()" />
</template>
<script>
import imageMixin from '~/mixins/image'
export default {
name: 'New',
mixin: { imageMixin }
}
</script>
<style scoped></style>
解决方案
Change mixin: { imageMixin }
to mixins: [imageMixin]
推荐阅读
- file - 无论文件在 Java 8 ro Java 10 中的扩展名如何,我如何对文件进行密码保护
- authentication - 使用 AXIOS 进行 JWT 身份验证
- c# - 如何在 ef core 中使用 fluent API 添加复合主键?
- mysql - 如何创建 MySQL 视图以通过相关表显示嵌套集模型中每个节点的所有路径?
- mysql - 如果第二个表具有条件值,则插入表中
- algorithm - 将数组划分为具有最小总方差的子集的算法
- javascript - undercore _.sortBy 未正确排序数组对象
- laravel - 在远程服务器上创建符号链接设置 Laravel 5.6
- angular - I used mat-table in angular 6 application to display the data but the result is coming as empty spaces
- javascript - JavaScript/jQuery 在脚本中添加锚标记