提交 5101fdd6 编写于 作者: fxy060608's avatar fxy060608

feat(nvue): navigator

上级 bf648f56
......@@ -81,21 +81,40 @@ export function initComponents(uni, Vue, weex) {
}
};
}
function useHoverClass(hoverClass) {
if (hoverClass && hoverClass !== "none") {
return {};
const hasOwnProperty = Object.prototype.hasOwnProperty;
const hasOwn = (val, key) => hasOwnProperty.call(val, key);
function useHoverClass(props) {
if (props.hoverClass && props.hoverClass !== "none") {
const hoverAttrs = { hoverClass: props.hoverClass };
if (hasOwn(props, "hoverStartTime")) {
hoverAttrs.hoverStartTime = props.hoverStartTime;
}
if (hasOwn(props, "hoverStayTime")) {
hoverAttrs.hoverStayTime = props.hoverStayTime;
}
if (hasOwn(props, "hoverStopPropagation")) {
hoverAttrs.hoverStopPropagation = props.hoverStopPropagation;
}
return hoverAttrs;
}
return { hoverClass };
return {};
}
const navigatorStyles = [{
"navigator-hover": {
backgroundColor: "rgba(0,0,0,0.1)",
opacity: 0.7
}
}];
var Navigator = vue.defineComponent({
name: "Navigator",
props: navigatorProps,
styles: navigatorStyles,
setup(props, {
slots
}) {
const onClick = createNavigatorOnClick(props);
return () => {
return vue.createVNode("div", vue.mergeProps(useHoverClass(props.hoverClass), {
return vue.createVNode("view", vue.mergeProps(useHoverClass(props), {
"onClick": onClick
}), [slots.default && slots.default()]);
};
......
......@@ -5,16 +5,26 @@ import {
} from '../../components/navigator'
import { useHoverClass } from '../utils'
const navigatorStyles: Record<string, Record<string, string | number>>[] = [
{
'navigator-hover': {
backgroundColor: 'rgba(0,0,0,0.1)',
opacity: 0.7,
},
},
]
export default defineComponent({
name: 'Navigator',
props: navigatorProps,
styles: navigatorStyles,
setup(props, { slots }) {
const onClick = createNavigatorOnClick(props)
return () => {
return (
<div {...useHoverClass(props.hoverClass)} onClick={onClick}>
<view {...useHoverClass(props)} onClick={onClick}>
{slots.default && slots.default()}
</div>
</view>
)
}
},
......
export function useHoverClass(hoverClass: string) {
if (hoverClass && hoverClass !== 'none') {
return {}
import { hasOwn } from '@vue/shared'
interface HoverProps {
hoverClass?: string
hoverStartTime?: number | string
hoverStayTime?: number | string
hoverStopPropagation?: boolean
}
export function useHoverClass(props: HoverProps) {
if (props.hoverClass && props.hoverClass !== 'none') {
const hoverAttrs: HoverProps = { hoverClass: props.hoverClass }
if (hasOwn(props, 'hoverStartTime')) {
hoverAttrs.hoverStartTime = props.hoverStartTime
}
if (hasOwn(props, 'hoverStayTime')) {
hoverAttrs.hoverStayTime = props.hoverStayTime
}
if (hasOwn(props, 'hoverStopPropagation')) {
hoverAttrs.hoverStopPropagation = props.hoverStopPropagation
}
return hoverAttrs
}
return { hoverClass }
return {}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册