我目前正在尝试将自定义数据属性设置为TextField组件,例如:
class TestTextField extends React.Component {
componentDidMount() {console.log(this._input)}
render() {
return (
<TextField
label="Label 1"
InputProps={{placeholder: 'Input 1', 'data-state': 'Data State 1'}}
margin="normal"
inputRef={(elem) => {this._input = elem}}
/>
)
}
}
Run Code Online (Sandbox Code Playgroud)
但是我无法data-state出现在控制台日志中
<textarea rows="1" class="MuiTextarea-textarea-67 MuiInput-input-56 MuiInput-inputMultiline-64" placeholder="Input 1" type="text">
Run Code Online (Sandbox Code Playgroud)
TextField不支持自定义属性吗?我正在使用v1.0.0-beta.6(https://material-ui-1dab0.firebaseapp.com/api/text-field/)
如何记录扩展 EventEmitter 以在 VS Code 中工作的类的事件?我找不到任何工作示例,也找不到除此之外没有任何示例的任何示例。它链接到的页面(https://jsdoc.app/tags-event.html)似乎也不起作用,因为我试图复制它:
class Test extends EventEmitter {
/**
* @fires Test#name
*/
run () {
this.emit('name', 1)
}
}
/**
* Snowball Event
* @event Test#name
* @type {number}
*/
const t = new Test()
t.run()
t.on('')
Run Code Online (Sandbox Code Playgroud)
name当我尝试编写.VS Code 时,VS Code 似乎没有检测到这是一个已记录的事件t.on('。(我也尝试过将其放在@fires运行方法之上)
我当前正在尝试从模块打开保存在缓存中的图像react-native-camera。根据这个来自React Native 应用程序的 Open android Gallery App,他们在传递content://url 而不是file://url 时设法做到了这一点,但经过一些研究,我找不到任何有关将文件 uri 转换为内容的内容 - 只有相反。我可以通过以下方式获取图像文件路径:
import RNFS from 'react-native-fs'
import { Linking } from 'react-native'
RNFS.readDir(RNFS.CachesDirectoryPath)
.then(arr => RNFS.readDir(arr[0].path)) // The Camera directory
.then(arr => arr.forEach(item => {
const contentURI = somehowConvertPathToContentURI(item.path)
Linking.canOpenURL(contentURI)
.then(able => able ? Linking.openURL(contentURI) : console.log('No application available'))
.catch(console.log)
}))
.catch(console.log)
Run Code Online (Sandbox Code Playgroud)
记录的路径将是/data/user/0/com.myapp/cache/Camera/ad8db2ca-4739-47cc-b18d-c5147c8c26e0.jpg. 在前面添加file://会给我文件uri,怎么样content://?
作为旁注,如果我读取图像并将其转换为 Base64 react-native-fs,然后将 Base64 提供给 React-Native 的<Image>组件,我就可以直接显示图像 - …
在 TypeScript 中,假设我想让用户使用我模块的“内部”类型,以便他们在使用我的模块时可以正确键入他们自己的变量 - 我是否只是从我的 index.ts 文件中导出所有内容来完成此操作?
// index.ts
export * from './file1' // uses types/interfaces defined in file1types
export * from './file2' // uses types/interfaces defined in file2types
export * from './types/file1types'
export * from './types/file2types'
Run Code Online (Sandbox Code Playgroud)
我曾尝试阅读 TypeScript 声明文件,但有关这方面的信息非常零散。.d.ts文件是否可以帮助我完成此任务,还是仅适用于非 TS 项目?tsconfig.json的选项是否declaration: true通过.d.ts为每个 TS 文件生成一个来帮助我完成此操作?这是从单个 index.ts 文件导出所有内容的替代方法吗?
如果declaration: true确实可以帮助我完成此操作,用户将如何使用.d.ts文件build夹中所有生成的文件?
我非常感谢您对 TS 项目中通常如何导出类型的一些说明。提前致谢。
javascript ×2
node.js ×2
es6-class ×1
jsdoc ×1
material-ui ×1
node-modules ×1
react-native ×1
reactjs ×1
typescript ×1