本帖最后由 kqs42 于 2023-5-20 11:25 编辑
测试网址:https://element-plus.gitee.io/zh-CN/component/notification.html
描述:网站用的是vue3+lement-plus框架。
需求:用油猴脚本触发网站本身的Notification通知组件。
官方给出的示例是click触发,我想用油猴脚本直接触发。
<template>
<el-button plain @click="open1"> Closes automatically </el-button>
<el-button plain @click="open2"> Won't close automatically </el-button>
</template>
<script lang="ts" setup>
import { h } from 'vue'
import { ElNotification } from 'element-plus'
const open1 = () => {
ElNotification({
title: 'Title',
message: h('i', { style: 'color: teal' }, 'This is a reminder'),
})
}
const open2 = () => {
ElNotification({
title: 'Prompt',
message: 'This is a message that does not automatically close',
duration: 0,
})
}
</script>