@webileapps/nativescript-radiobutton
一个为 NativeScript 提供原生单选组(radiogroup)和单选按钮(radiobutton)视图元素的插件。
npm i --save @webileapps/nativescript-radiobutton
- 版本:0.2.7
- GitHub: https://github.com/WebileApps/nativescript-radiobutton
- NPM: https://npmjs.net.cn/package/%40webileapps%2Fnativescript-radiobutton
- 下载
- 昨天:0
- 上周:0
- 上个月:0
NativeScript-RadioButton
这是其他 NativeScript 插件的一个分支,用于原生单选组和单选按钮小部件。
与原始插件相比的更改
- 支持
tintColor
XML 属性(或tint-color
CSS 属性)。 - 确保
color
XML(和 CSS 属性)正确工作。
使用的平台控件
Android | iOS |
---|---|
Android RadioGroup | 无 |
Android RadioButton | 无 |
安装
在您的命令提示符/终端中,转到您的应用程序根目录并执行
tns plugin add @webileapps/nativescript-radiobutton
使用方法
示例应用程序
如果您想要快速开始,请克隆存储库,cd src
,然后执行以下命令
npm install
npm run demo.android
Angular
导入 NgModule 以使用
import { RadioButtonModule } from '@webileapps/nativescript-radiobutton/angular'
@NgModule({
imports: [
RadioButtonModule
]
})
将其放置在您的视图中。
<StackLayout>
<RadioGroup [(value)]="dataBoundVariable">
<RadioButton text="Selection 1"></RadioButton>
<RadioButton text="Selection 2"></RadioButton>
<RadioButton text="Selection 3"></RadioButton>
</RadioGroup>
</StackLayout>
NativeScript-Vue
在您的 main.js
中注册 RadioGroup
和 RadioButton
元素
Vue.registerElement('RadioGroup', () => require('@webileapps/nativescript-radiobutton').RadioGroup)
Vue.registerElement('RadioButton', () => require('@webileapps/nativescript-radiobutton').RadioButton)
然后在您的模板中使用它
<RadioGroup
@selected="onSelected">
<RadioButton
v-for="item in someList"
:key="item.id"
:text="item.text">
</RadioButton>
</RadioGroup>
支持属性
RadioButton
Android | 示例 |
---|---|
enabled | enabled="true | false" |
text | text="字符串" |
checked | checked="true | false" |
RadioGroup
Android | 返回 |
---|---|
value | 所选单选按钮的索引 |
支持事件
RadioGroup
Android | 类型 |
---|---|
value | EventEmitter |