监听点击元素外部的事件。
<div ref="root" />
import { ref } from "vue";
import { useClickAway } from "@vant/use";
export default {
setup() {
const root = ref();
useClickAway(root, () => {
console.log("click outside!");
});
return { root };
},
};
通过 eventName 选项可以自定义需要监听的事件类型。
<div ref="root" />
import { ref } from "vue";
import { useClickAway } from "@vant/use";
export default {
setup() {
const root = ref();
useClickAway(
root,
() => {
console.log("touch outside!");
},
{ eventName: "touchstart" }
);
return { root };
},
};
type Options = {
eventName?: string;
};
function useClickAway(
target: Element | Ref<Element | undefined>,
listener: EventListener,
options?: Options
): void;
参数 | 说明 | 类型 | 默认值 |
---|---|---|---|
target | 绑定事件的元素 | Element | Ref<Element> | - |
listener | 点击外部时触发的回调函数 | EventListener | - |
options | 可选的配置项 | Options | 见下表 |
参数 | 说明 | 类型 | 默认值 |
---|---|---|---|
eventName | 监听的事件类型 | string | click
|
在同一个选择器里选择日期和时间日期和时间点通过设置isShowTime,即可在同一个选择器里同时进行日期和时间的选择。快捷选项的使...
Checkbox 多选框一组备选项中进行多选基础用法单独使用可以表示两种状态之间的切换,写在标签中的内容为 checkbox 按钮后的介绍...
通过拖动滑块在一个固定区间内进行选择基础用法在拖动滑块时,显示当前值通过设置绑定值自定义滑块的初始值templatediv class="b...
Progress 进度条用于展示操作进度,告知用户当前状态和预期。线形进度条Progress 组件设置percentage属性即可,表示进度条对应的...
使用tooltip设置该主题河流图特定的提示框浮层,本节介绍了此提示框浮层的一些属性。主题河流图提示框浮层属性position注意:ser...
ECharts 中提示框组件可以在多种地方使用,如:可以设置在全局,即tooltip可以设置在坐标系中,即grid.tooltip、polar.tooltip、...
graphic.elements[i]-ringECharts 圆环图形元素配置。graphic.elements[i]-ring.type |string[ default: ring ]用 setOption 首...
Highcharts 反向条形图Highcharts 条形图以下实例演示了使用负值的,反向条形图。实例文件名:highcharts_bar_negative.htmhtmlh...