Iview: 在render 模式下 JSX语法 Radio 组件 使用<Radio></Radio> 或者 <i-radio></i-radio>报错

Created on 18 Sep 2017  ·  3Comments  ·  Source: iview/iview

问题:在render模式下 jsx 使用Radio 组件会报如下错误:

Error in render function: "ReferenceError: Radio is not defined"
不使用jsx语法 h('Radio',null,'')是可以的
期望: 使用jsx语法 Radio组件的正确使用方式是什么? 查阅相关文档 并没有说到Radio组件

Most helpful comment

是在table 的render模式下 ,iview是全局导入的
原来代码
{
title: "选择",
key: "1",
render:(h, {row})=>{
return <Radio></Radio>
}
}, 报错
然后我发现 解析 把Radio解析成了变量而不是字符串 ,解析后代码
{
title: "选择",
key: "1",
render:(h, {row})=>{
return h(Radio,{},null) ; 此处的Radio 是一个变量 所以报错! 应该是字符串才对
}
}
于是我改成这样
{
title: "选择",
key: "1",
render:(h, {row})=>{
let Radio='Radio';
return <Radio></Radio>
}
}, 就可以了

All 3 comments

需要 import import { Radio } from 'iview'

是在table 的render模式下 ,iview是全局导入的
原来代码
{
title: "选择",
key: "1",
render:(h, {row})=>{
return <Radio></Radio>
}
}, 报错
然后我发现 解析 把Radio解析成了变量而不是字符串 ,解析后代码
{
title: "选择",
key: "1",
render:(h, {row})=>{
return h(Radio,{},null) ; 此处的Radio 是一个变量 所以报错! 应该是字符串才对
}
}
于是我改成这样
{
title: "选择",
key: "1",
render:(h, {row})=>{
let Radio='Radio';
return <Radio></Radio>
}
}, 就可以了

如下也可以: @fengyaogit123

import iView from 'iview';
{
    render: h => <iView.Radio></iView.Radio>
}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

kengqiangxia picture kengqiangxia  ·  3Comments

ai116458960 picture ai116458960  ·  3Comments

hellomrbigshot picture hellomrbigshot  ·  3Comments

chenhaizano picture chenhaizano  ·  3Comments

lvqingan picture lvqingan  ·  3Comments