storybook - 强制状态,例如为故事书中的复选框检查 =“true”?
问题描述
我有自定义样式的复选框。Storybook 中有没有办法让复选框被选中,这样您就不必单击它来查看此状态?
解决方案
这是一项正在进行的工作,尚未完全发挥作用,但它确实通过了道具,所以我只是让故事书合作。
故事书插件伪状态真的应该内置这个......
我正在使用 jsx 方法,但差异可以忽略不计。
我昨晚刚开始学习 Vue 和 storybook,所以这对我来说很新,我稍后会发布一个功能齐全的版本。
Checkbox.stories.js
export const CheckBoxChecked = Template.bind({});
CheckBoxChecked.args = {
label: 'Checked',
checked: true,
};
复选框.jsx
import Vue from 'vue';
import { styled, VueEmotion } from '@egoist/vue-emotion';
import './checkbox.css';
Vue.use(VueEmotion);
const Label = styled('label')`
`
const Input = styled('input')`
opacity: 0;
width: 1em;
height: 1em;
`
export default {
name: 'CheckBox',
props: {
label: {
type: String,
required: true,
},
checked: {
type: Boolean,
default: false
},
render (h) {
return (
<Label>
<Input type="checkbox" checked={this.checked} />
</Label>
)
}
}
推荐阅读
- arrays - Groovy 检查数组包含字符串与文字字符串和连接字符串的工作方式不同
- batch-file - 如何使用 bat 在命令提示符下执行 2 个命令目录行。文件
- python - sqlalchemy:防止关系对象自动添加到会话中
- elasticsearch - 如何在 elasticsearch 上运行自定义 lucene 编解码器?
- android - 如何使网络浏览器可以访问android应用程序
- c# - Github 项目上的错误-“值不能为空”、“未设置内核索引 (1) 处的属性 (particleBuffer)”
- android - 无法应用短信中的上下文
- node.js - 正文解析器不使用 POST-MAN 表单数据
- python - 如何从 Google 新闻 RSS 中抓取 Google 新闻文章内容?
- python-2.7 - 让 scipy 接受丢失的数据