Comments (3)
这是因为受控模式导致的,菜单会优先使用 show-menu
这个 props
来控制显示状态。
你将 show-menu
设置为 true
的需求是什么呢,或许我们可以根据需求来探讨更好的使用方式。
from naive-ui.
这是因为受控模式导致的,菜单会优先使用
show-menu
这个props
来控制显示状态。你将
show-menu
设置为true
的需求是什么呢,或许我们可以根据需求来探讨更好的使用方式。
我希望是初始状态为显示让用户知道这个菜单有哪些功能,然后为了为了方便阅读,可以对菜单进行收缩和展开
from naive-ui.
这是因为受控模式导致的,菜单会优先使用
show-menu
这个props
来控制显示状态。
你将show-menu
设置为true
的需求是什么呢,或许我们可以根据需求来探讨更好的使用方式。我希望是初始状态为显示让用户知道这个菜单有哪些功能,然后为了为了方便阅读,可以对菜单进行收缩和展开
创建一个初始值为 true
变量,假设是 const showMenu = ref(true)
,然后给组件加上 v-model:show-menu="showMenu"
应该就可以解决了。
有一种特殊情况是,当 menu-trigger
为 'hover' 的时候,鼠标外部移动会使 FloatButton
自动隐藏。如果你希望用户在首次碰到 FloatButton
的之前 FloatButton
不要自动隐藏,你可以自主监听 mousemove
事件,然后调控 showMenu
的受控行为,例如:
const floatButtonRef = ref();
const showMenu = ref(true);
let allowModifyShowMenu = false;
const setShowMenu = (value: boolean) => {
if (allowModifyShowMenu) {
showMenu.value = value;
}
};
const handleMousemove = (e: MouseEvent) => {
if (floatButtonRef.value?.$el.contains(e.target)) {
allowModifyShowMenu = true;
document.removeEventListener("mousemove", handleMousemove);
}
};
document.addEventListener("mousemove", handleMousemove);
这里是在线用例 https://codesandbox.io/p/sandbox/wonderful-lovelace-vc32yp?file=%2Fsrc%2FDemo.vue%3A41%2C1-59%2C57
from naive-ui.
Related Issues (20)
- 【n-select】能不能手动focus的时候,自动将下拉框打开 HOT 2
- 'pnpm lint' results in TypeError: Converting circular structure to JSON HOT 1
- 希望Code组件可以自定义起始行号
- 500 document is not defined when using n-popover in Nuxt3 HOT 3
- 导出excel乱码 HOT 2
- Select组件支持分页异步加载
- n-upload的照片墙功能
- 【Calendar】日历组件希望可以增加一个右上角切换月份的功能区插槽,或者合并到header插槽
- Tab 初始化时无法填值
- Upload 组件 data 属性为函数时,直接获取形参 file.name 返回 undefined HOT 3
- 支持 DataTable 不同列的 filter 结果取并
- [NDataTable] 在没有数据的情况下,不会有横向滚动条 HOT 2
- 上传组件除了图片类型,其他类型缩略图都不生效 HOT 1
- Drawer组件添加一个lazy属性,指定是否懒挂载 HOT 1
- 建议:n-upload组件添加一个重新上传回调方法
- 需求:为Cascader增加API:render-prefix和render-suffix HOT 2
- n-input组件添加失焦后更新值属性 HOT 1
- n-select组件添加失焦后更新值属性 HOT 2
- 组件文档 出现错误 HOT 1
- [feat] Allow mask of model be in certain block
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from naive-ui.