-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Open
Labels
F-reactFramework - ReactFramework - ReactT-alipayTarget - 编译到支付宝小程序Target - 编译到支付宝小程序V-3Version - 3.xVersion - 3.x
Description
相关平台
支付宝小程序
小程序基础库: 无
使用框架: React
复现步骤
import React, { useState } from 'react'
import { View } from '@tarojs/components'
import { AtSearchBar } from "taro-ui"
// import { debounce } from 'lodash' 此方法引入,页面加载失败,报错为 TypeError: Cannot read property 'prototype' of undefined
import { debounce } from 'lodash/function' 此方法引入,页面正常加载,当触发onChange 事件时,报错为 TypeError: Cannot read property 'now' of undefined
import "taro-ui/dist/style/components/search-bar.scss"
import "taro-ui/dist/style/components/list.scss"
import "taro-ui/dist/style/components/icon.scss"
import './index.scss'
export default function Search() {
const [mine, setMine] = useState({ list: [] }),
[search, setSearch] = useState({ list: [], search: { value: '' }, disabled: false, fixed: true }),
[debounceOptions, setDebounceOptions] = useState({
wait: 800, options: {
'leading': true,
'trailing': false
}
})
const handleSearch = ((e) => {
return debounce((e, options) => {
onSearch(e, options)
}, debounceOptions.wait, {
'leading': false,
'trailing': true
})
})()
const onSearch = (e, options) => {
console.log('onChange', e, options)
}
return (
<View className="page">
<AtSearchBar
actionName='搜一下'
value={search.search.value}
disabled={search.disabled}
fixed={search.fixed}
onChange={handleSearch}
onActionClick={handleSearch}
/>
</View>
)
}
期望结果
期望无报错
实际结果
h5与微信小程序无报错,支付宝小程序报错为:
import { debounce } from 'lodash' 此方法引入,页面加载失败,报错为 TypeError: Cannot read property 'prototype' of undefined
or
import { debounce } from 'lodash/function' 此方法引入,页面正常加载,当触发onChange 事件时,报错为 TypeError: Cannot read property 'now' of undefined
环境信息
👽 Taro v3.0.16
Taro CLI 3.0.16 environment info:
System:
OS: macOS 11.0.1
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 12.0.0 - ~/.nvm/versions/node/v12.0.0/bin/node
Yarn: 1.19.1 - ~/.nvm/versions/node/v10.0.0/bin/yarn
npm: 6.9.0 - ~/.nvm/versions/node/v12.0.0/bin/npm
npmPackages:
@tarojs/components: 3.0.16 => 3.0.16
@tarojs/mini-runner: 3.0.16 => 3.0.16
@tarojs/react: 3.0.16 => 3.0.16
@tarojs/runtime: 3.0.16 => 3.0.16
@tarojs/taro: 3.0.16 => 3.0.16
@tarojs/webpack-runner: 3.0.16 => 3.0.16
babel-preset-taro: 3.0.16 => 3.0.16
eslint-config-taro: 3.0.16 => 3.0.16
react: ^16.10.0 => 16.14.0
taro-ui: ^3.0.0-alpha.3 => 3.0.0-alpha.3
Metadata
Metadata
Assignees
Labels
F-reactFramework - ReactFramework - ReactT-alipayTarget - 编译到支付宝小程序Target - 编译到支付宝小程序V-3Version - 3.xVersion - 3.x