如何使用 JS Fiddle 来渲染 React select
How to use JS Fiddle for rending React select
我想在 JS Fiddle 中渲染第三方库 react-select。我在 jsfiddle 中添加了库,但不确定如何使用 react-select 中的 Select 组件。我收到“错误 Select 未定义”。
https://jsfiddle.net/7nydx09p/1/
const App = () => {
return <div> Test
<Select />
</div>
}
ReactDOM.render(<App/>, document.getElementById('root'));
看这里:https://jsfiddle.net/zh4593oL/1/
在此处查找问题:https://github.com/JedWatson/react-select/issues/4120
html
<div id="root"></div>
<script type="module">
import Select from 'https://cdn.pika.dev/react-select@^3.1.0';
window.Select = Select;
</script>
js
const options = [
{ value: 'chocolate', label: 'Chocolate' },
{ value: 'strawberry', label: 'Strawberry' },
{ value: 'vanilla', label: 'Vanilla' },
];
const App = () => {
return <div> <Select options={options} /> </div>
}
ReactDOM.render(<App/>, document.getElementById('root'));
我想在 JS Fiddle 中渲染第三方库 react-select。我在 jsfiddle 中添加了库,但不确定如何使用 react-select 中的 Select 组件。我收到“错误 Select 未定义”。
https://jsfiddle.net/7nydx09p/1/
const App = () => {
return <div> Test
<Select />
</div>
}
ReactDOM.render(<App/>, document.getElementById('root'));
看这里:https://jsfiddle.net/zh4593oL/1/
在此处查找问题:https://github.com/JedWatson/react-select/issues/4120
html
<div id="root"></div>
<script type="module">
import Select from 'https://cdn.pika.dev/react-select@^3.1.0';
window.Select = Select;
</script>
js
const options = [
{ value: 'chocolate', label: 'Chocolate' },
{ value: 'strawberry', label: 'Strawberry' },
{ value: 'vanilla', label: 'Vanilla' },
];
const App = () => {
return <div> <Select options={options} /> </div>
}
ReactDOM.render(<App/>, document.getElementById('root'));