Skip to content

Commit

Permalink
fix: 修复demo的warning和修复detail无法赋值的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
三少 committed Sep 28, 2021
1 parent ee0343a commit 63eff14
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 28 deletions.
55 changes: 30 additions & 25 deletions packages/vantui-demo/src/pages/index/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,19 +120,19 @@ export default function Index() {
{/* <MiniNavBar title="标题" homeUrl="/pages/demo2/index" /> */}
<Progress percentage={50} strokeWidth={4} />
<Grid>
<GridItem icon="photo-o" text="文字" />
<GridItem icon="photo-o" text="文字" />
<GridItem icon="photo-o" text="文字" />
<GridItem icon="photo-o" text="文字" />
<GridItem key={0} icon="photo-o" text="文字" />
<GridItem key={1} icon="photo-o" text="文字" />
<GridItem key={2} icon="photo-o" text="文字" />
<GridItem key={3} icon="photo-o" text="文字" />
</Grid>
<DropdownMenu>
<DropdownItem value={value1} options={option1} />
<DropdownItem value={value2} options={option2} />
<DropdownItem key={0} value={value1} options={option1} />
<DropdownItem key={1} value={value2} options={option2} />
</DropdownMenu>
<View>
<Icon name="chat" size={40} dot />
<Icon name="chat" size={40} info="9" />
<Icon name="chat" size={40} info="99+" />
<Icon key={0} name="chat" size={40} dot />
<Icon key={1} name="chat" size={40} info="9" />
<Icon key={2} name="chat" size={40} info="99+" />
</View>
<DatetimePicker
type="datetime"
Expand All @@ -147,9 +147,9 @@ export default function Index() {
<Slider value={50} onChange={SliderOnChange} />

<Sidebar activeKey={1}>
<SidebarItem title="标签名" />
<SidebarItem title="标签名" />
<SidebarItem title="标签名" />
<SidebarItem key={0} title="标签名" />
<SidebarItem key={1} title="标签名" />
<SidebarItem key={2} title="标签名" />
</Sidebar>

{/* <View>
Expand Down Expand Up @@ -249,7 +249,7 @@ export default function Index() {
}}
/>
</View>
<Tabs active={0} swipeable swipe-threshold={5}>
{/* <Tabs active={0} swipeable swipe-threshold={5}>
<Tab title="标签 1">内容 1</Tab>
<Tab title="标签 2">内容 2</Tab>
<Tab title="标签 3">内容 3</Tab>
Expand All @@ -260,22 +260,22 @@ export default function Index() {
内容 3
</Tab>
<Tab title="标签 4">内容 4</Tab>
</Tabs>
</Tabs> */}

{/* <Tabs active={0}>
<Tab title="标签 11">
<Tabs active={0}>
<Tab key={0} title="标签 11">
内容 11
</Tab>
<Tab title="标签 22">
<Tab key={1} title="标签 22">
内容 22
</Tab>
<Tab title="标签 33">
<Tab key={2} title="标签 33">
内容 33
</Tab>
<Tab title="标签 44">
<Tab key={3} title="标签 44">
内容 44
</Tab>
</Tabs> */}
</Tabs>
<View
id="container"
style={{ marginTop: '200px', height: '200px', background: 'red' }}
Expand Down Expand Up @@ -317,11 +317,16 @@ export default function Index() {
onConfirm={onConfirm}
/>
<GoodsAction>
<GoodsActionIcon icon="chat-o" text="客服" />
<GoodsActionIcon icon="cart-o" text="购物车" info="5" />
<GoodsActionIcon icon="shop-o" text="店铺" />
<GoodsActionButton color="#7232dd" text="加入购物" type="warning" />
<GoodsActionButton plain color="#7232dd" text="立即购买" />
<GoodsActionIcon key={0} icon="chat-o" text="客服" />
<GoodsActionIcon key={1} icon="cart-o" text="购物车" info="5" />
<GoodsActionIcon key={2} icon="shop-o" text="店铺" />
<GoodsActionButton
key={3}
color="#7232dd"
text="加入购物"
type="warning"
/>
<GoodsActionButton key={4} plain color="#7232dd" text="立即购买" />
</GoodsAction>
{/* <Tabbar active={1}>
<TabbarItem icon="home-o">标签</TabbarItem>
Expand Down
13 changes: 12 additions & 1 deletion packages/vantui/src/components/field/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ export default function Index(props: FieldProps) {

const emitChange = function (event?: any) {
event = event || { detail: { value: '' } }
event.detail = event.detail.value
Object.defineProperty(event, 'detail', {
value: event.detail.value,
})
setState((pre: any) => {
return { ...pre, innerValue: event.detail }
})
Expand Down Expand Up @@ -115,11 +117,17 @@ export default function Index(props: FieldProps) {
const _focus = function (event: any) {
ref.current.focused = true
setShowClear(innerValue)
Object.defineProperty(event, 'detail', {
value: event.detail.value,
})
onFocus?.(event)
}
const _blur = function (event: any) {
ref.current.focused = false
setShowClear(innerValue)
Object.defineProperty(event, 'detail', {
value: event.detail.value,
})
onBlur?.(event)
}
const _clear = function () {
Expand All @@ -135,6 +143,9 @@ export default function Index(props: FieldProps) {
const _confirm = function (event: any) {
const { value = '' } = event.detail || {}
setShowClear(value)
Object.defineProperty(event, 'detail', {
value: event.detail.value,
})
onConfirm?.(event)
}
// setValue(value) {
Expand Down
4 changes: 3 additions & 1 deletion packages/vantui/src/components/rate/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ export default function Index(props: RateProps) {

const onSelect = function (event: ITouchEvent) {
const { score } = event.currentTarget.dataset
event.detail = score
Object.defineProperty(event, 'detail', {
value: score,
})
if (!disabled && !readonly) {
setInnerValue(score + 1)
Taro.nextTick(() => {
Expand Down
1 change: 0 additions & 1 deletion packages/vantui/src/components/tabs/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ export default function Index(props: TabsProps) {
} = props
const tabs = parseTabList(children)
const newChildren: any = tabs.map((tab, index) => {
console.log(currentIndex, index)
return cloneElement(tab.node, {
key: tab.key,
active: currentIndex === index,
Expand Down

0 comments on commit 63eff14

Please sign in to comment.