如果“无法”,则CASL呈现子组件

时间:2018-11-24 20:45:45

标签: javascript reactjs authorization casl

如果用户“无法”执行某项操作,如何使用text=input("Please enter the string to encode") encoded=[] index=0 amount=1 while index<=(len(text)-1): if index==(len(text)-1) or text[index]!=text[(index+1)]: encoded.append((text[index],amount)) amount=1 else: amount=amount+1 index=index+1 print(encoded) 显示子组件?

我之所以问这个问题,是因为如果用户未被授权但处于禁用状态,我仍然想渲染组件。

示例:

我想做什么:

@casl/react

2 个答案:

答案 0 :(得分:0)

忘了我只能检查一下能力

<button disabled={!abilities.can('update', 'style')}> Update </button>

答案 1 :(得分:0)

<Can>支持not道具:

<Can not do="update" on="style">...</Can>

https://github.com/stalniy/casl/blob/master/packages/casl-react/README.md#3-property-names-and-aliases