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)
- 关于Tree组件的拖拽
- n-tree 组件的TreeOption类型添加泛型
- 支持自定义组件的标签名
- 我觉得可能存在内存溢出的风险。
- 轮播图使用draggable时从左往右滑动时切换异常
- Command palette组件 HOT 1
- 是否会出类似于Lobe UI的这种用于构建 AIGC 网页应用的组件
- Add a horizontal virtual scroll to NDataTable HOT 1
- Cascader组件搜索筛选下拉列表显示不全 HOT 2
- 需求:示例是否可以改成使用Setup语法糖模式,拜托了 HOT 1
- 希望Date Picker组件shortcuts,如果是函数的话,可以吧event返回回来。Hopefully the Date Picker component shortcuts, and if it's a function, you can return the event back! HOT 1
- qrcode 组件的中间icon的image设置跨域 HOT 2
- 组件 transfer 能否增加prop用于自定义头部
- Message内容为纯数字或纯字母的时候不能 HOT 1
- 组件内使用NFormItemGi组件无法渲染、是否应该找内层的NFormItemGi组件 HOT 3
- 希望表单能在长表单的时候自动滚到错误位置
- DatePicker 组件 能够自定义 `此刻` `确认`和`清除`按钮 HOT 3
- 轮播图carousel,props属性defaultIndex不生效 HOT 4
- Need shortcut key component, set shortcut key binding in Electron or Web
- 希望Date Picker组件允许根据不同日期自定义每个日期单元格的内容或样式
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.