From your command prompt/terminal go to your app's root folder and execute:
ns plugin add @nstudio/nativescript-checkbox
tns plugin add @nstudio/nativescript-checkbox@1.0.0
Android | iOS |
---|---|
Android CheckBox | BEMCheckBox |
Android Sample | iOS Sample |
---|---|
<Page
xmlns="http://schemas.nativescript.org/tns.xsd"
xmlns:CheckBox="@nstudio/nativescript-checkbox" loaded="pageLoaded">
<ActionBar title="Native Checkbox" />
<StackLayout>
<CheckBox:CheckBox checked="{{ checkProp }}" text="{{ myCheckText }}" fillColor="{{ myCheckColor }}" id="myCheckbox" />
<CheckBox:CheckBox text="CheckBox Label" checked="false" />
</StackLayout>
</Page>
import { CheckBox } from '@nstudio/nativescript-checkbox';
import { topmost } from '@nativescript/core/ui/frame';
public toggleCheck() {
const checkBox = topmost().getViewById('yourCheckBoxId');
checkBox.toggle();
}
public getCheckProp() {
const checkBox = topmost().getViewById('yourCheckBoxId');
console.log('checked prop value = ' + checkBox.checked);
}
import { TNSCheckBoxModule } from '@nstudio/nativescript-checkbox/angular';
@NgModule({
imports: [TNSCheckBoxModule]
// etc.
})
export class YourModule {}
// component:
export class SomeComponent {
@ViewChild('CB1') FirstCheckBox: ElementRef;
constructor() {}
public toggleCheck() {
this.FirstCheckBox.nativeElement.toggle();
}
public getCheckProp() {
console.log(
'checked prop value = ' + this.FirstCheckBox.nativeElement.checked
);
}
}
<StackLayout>
<CheckBox #CB1 text="CheckBox Label" checked="false"></CheckBox>
<button (tap)="toggleCheck()" text="Toggle it!"></button>
<button (tap)="getCheckProp()" text="Check Property"></button>
</StackLayout>
In your main.js
(The file where the root Vue instance is created) register the element
Vue.registerElement(
'CheckBox',
() => require('@nstudio/nativescript-checkbox').CheckBox,
{
model: {
prop: 'checked',
event: 'checkedChange'
}
}
);
And in your template, use it as:
<check-box :checked="isChecked" @checkedChange="isChecked = $event.value" />
Use checked
instead of v-model
. See #99.
circle
on iOS and square
on Android? Just make the boxType
value conditional.checked
property when this event fires to see the new value.Add the following to app/App_Resources/Android/drawable/checkbox_grey.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false" android:state_checked="true" android:drawable="@drawable/ic_checkbox_checked_incomplete" />
<item android:state_enabled="false" android:state_checked="false" android:drawable="@drawable/ic_checkbox_grey_incomplete" />
<item android:state_checked="true" android:drawable="@drawable/ic_checkbox_checked_grey"/>
<item android:state_checked="false" android:drawable="@drawable/ic_checkbox_grey" />
</selector>
Want to use radiobutton behavior for your checkboxes (only one option possible within a group)?Set boxType="circle"
and check out the second tab in the Angular demo, here's a screenshot:
npm run demo.android
npm run demo.ios
npm run demo.ng.android
(for angular android)npm run demo.ng.ios
(for angular ios)需求是el-tree 的子级 需要在: 展开父级时 勾选父级复选框时 加载子级数据并渲染dom结构。 需求1 还是比较好做的,官方有实例说明; 需求2 的话,翻了下element ui的源码, checkBox上直接加了@click.native.stop T^T 也就是说点击checkBox的时候根本不会触发loadNode 这个方法 没办法只能去找手动触发的方法了,翻了一遍果然有!!! nod
<template> <div class="contanier"> <el-checkbox-group v-model="checkVal" @input="onChange"> <el-checkbox v-for="item in checkList" :key="item.id" :label="item.name"
本demo是 一个弹窗页面,append-to-body 是element-ui 自带弹窗层级排序,v-dialogDrag 是弹窗拖拽(非element-ui自带 不用去掉即可),本文只是介绍简单版的 页面选中记忆,后续文章将讲述再细一层,双层的 页面选中记忆; <template> <div style="margin-bottom: 20px;"> <el-dialog :ti
NativeScript 可以使用 Javascript,CSS, XML 创建真正的 Native 跨平台应用,支持 iOS Android,NativeScript 将您的跨平台代码翻译成目标平台的代码。 UI 使用 XML 描述,CSS 样式,在编译时将 UI 转化成本地原生代码,最终得到正在的 Native 原生应用。 Telerik 公开了用于创建安卓、iOS和Windows Unive
NativeScript Command-Line Interface The NativeScript CLI lets you create, build, and deploy NativeScript-based apps on iOS and Android devices. Get it using: npm install -g nativescript What is Native
NativeScript-Snackbar �� �� �� NativeScript plugin for Material Design SnackBar component. Installation: NativeScript 7+:tns plugin add @nstudio/nativescript-snackbar NativeScript version prior to 7:t
Nativescript-Ripple This plugin aims to bring a native (or close to native) ripple implementation on Android and iOS. The android version uses a RippleDrawable and conserves the previous background, a
NativeScript-FloatingActionButton NativeScript plugin for Material Design Floating Action Button UI component. Installation Nativescript 7+: ns plugin add @nstudio/nativescript-floatingactionbutton Na
NativeScript CardView A NativeScript plugin to provide an XML widget to implement the Material Design CardView component. Installation NativeScript 7+: ns plugin add @nstudio/nativescript-cardview Nat
This project has moved: This project is now being maintained here: https://github.com/nativescript-community/ui-mapboxas it's become clear contrary to what I thought, I don't actually have enough time
Nativescript Hijri plugin This plugin is inspired by https://github.com/arabiaweather/hijri-date Nativescript-hijri Hijri plugin allow you to convert gregorian date to islamic hijri date. Installation