vue.js - v-tooltip 不显示其背后的组件
问题描述
我正在尝试按照他们文档中的示例实现v-tooltip,但我无法使其工作。如果我复制示例,我会收到此错误:
[Vue warn]: Property or method "on" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property.
如果我声明财产on
,则 btn 根本不会出现。
这是模板:
<v-tooltip bottom>
<template v-slot:activator="{ on }">
<v-btn color="primary" dark v-on="on">Bottom</v-btn>
</template>
<span>Bottom tooltip</span>
</v-tooltip>
解决方案
您可能会收到该错误,因为您使用的 Vue 版本不支持该v-slot
指令,该指令是在 Vue 版本 2.6 中添加的。
要么更新你的 Vue 版本,要么使用之前版本支持的 slot 语法:
<v-tooltip bottom>
<template slot="activator" slot-scope="{ on }">
<v-btn color="primary" dark v-on="on">Bottom</v-btn>
</template>
<span>Bottom tooltip</span>
</v-tooltip>
推荐阅读
- ionic3 - Android Opentok 上的 Ionic 3 Angular 5 应用程序崩溃
- asp.net-web-api - 响应状态码不表示成功:'400'('Bad request')
- datatables - 响应式数据表处理行点击
- perl - 如何使用 perl 脚本打乱文件内的行
- javascript - 有没有办法以编程方式撤销从firebase存储上的私有url生成的公共下载url?
- javascript - 引导日期选择器超出了网站的页脚
- java - 数组映射是否可能太少而无法包含大约 2000 个项目?
- java - 如何根据给定列表中的值存在从地图中删除条目?
- request - 如何使用 SMS 触发 API 请求?
- python - 无法使用 python 在 sqlite3 中创建数据库