Vue Multi Counter - Nativescript Typing CST Test
Loading…
Vue Multi Counter — Nativescript Code
Multiple independent counters in a single page.
<template>
<Page class="page">
<ActionBar title="Multi Counter" class="action-bar" />
<StackLayout class="container" horizontalAlignment="center" verticalAlignment="center">
<StackLayout v-for="(c, index) in counters" :key="index" class="counter-block">
<Label :text="`Counter ${index+1}: ${c}`" class="counter-text" />
<Button text="+" @tap="() => increment(index)" class="btn-primary" />
</StackLayout>
</StackLayout>
</Page>
</template>
<script>
import { ref } from 'vue';
export default {
setup() {
const counters = ref([0,0,0]);
const increment = (i) => counters.value[i]++;
return { counters, increment };
}
};
</script>
<style scoped>
.page { background-color: #fff; color: #000; }
.container { margin-top: 50px; text-align: center; }
.btn-primary { margin: 5px; }
.counter-text { font-size: 20px; margin-bottom: 10px; }
</style>Nativescript Language Guide
NativeScript is an open-source framework for building truly native mobile applications using JavaScript, TypeScript, Angular, or Vue. It allows developers to write cross-platform apps that access native APIs directly without using WebViews.
Primary Use Cases
- ▸Cross-platform native apps for iOS and Android
- ▸Enterprise apps requiring native performance
- ▸Apps needing access to full device APIs and native UI
- ▸Rapid prototyping of native mobile apps
- ▸Integration with Angular, Vue, or plain TypeScript/JavaScript front-end
Notable Features
- ▸Direct access to native UI components
- ▸Cross-platform with single codebase
- ▸Supports Angular, Vue, and plain TypeScript/JavaScript
- ▸Large ecosystem of plugins for device APIs
- ▸Open-source and actively maintained
Origin & Creator
Developed by Progress in 2015, NativeScript was created to bridge the gap between web development skills and native mobile development, providing a cross-platform solution without relying on WebViews.
Industrial Note
Perfect for enterprises and startups seeking cross-platform apps with fully native performance while leveraging existing JavaScript/TypeScript skills.
Quick Explain
- ▸NativeScript enables building native iOS and Android apps from a single codebase using familiar web technologies or TypeScript.
- ▸It provides direct access to native UI components and device APIs, offering true native performance.
- ▸Ideal for developers who want cross-platform apps with the look, feel, and performance of fully native applications.
Core Features
- ▸Native UI rendering for iOS and Android
- ▸CLI for project creation, building, and running apps
- ▸Plugin architecture to access native APIs
- ▸Support for TypeScript, Angular, Vue
- ▸Live sync and hot module replacement during development
Learning Path
- ▸Learn NativeScript CLI commands
- ▸Understand project structure and app folder
- ▸Explore plugins and native APIs
- ▸Integrate Angular or Vue with NativeScript
- ▸Build, test, and deploy native mobile apps
Practical Examples
- ▸Enterprise apps with native dashboards
- ▸Cross-platform mobile productivity apps
- ▸Apps requiring access to camera, GPS, or sensors
- ▸Consumer apps with high-performance UI
- ▸Rapid prototypes for mobile startups
Comparisons
- ▸NativeScript vs Cordova: NativeScript renders real native UI, Cordova uses WebView
- ▸NativeScript vs React Native: Both offer native UI, NativeScript supports Angular/Vue directly
- ▸True native performance vs hybrid approach
- ▸Plugin ecosystem differences
- ▸Steeper learning curve than Cordova, easier native integration than Flutter in JS/TS
Strengths
- ▸True native performance without WebView
- ▸Single codebase for multiple platforms
- ▸Rich plugin ecosystem
- ▸Seamless integration with popular frameworks
- ▸Active open-source community
Limitations
- ▸Smaller community than Cordova or React Native
- ▸Some plugins may require native code tweaks
- ▸Steeper learning curve for web-only developers
- ▸Larger app size than minimal native apps
- ▸Debugging native issues may require platform knowledge
When NOT to Use
- ▸Projects requiring pure web technologies
- ▸Teams with no TypeScript or Angular/Vue experience
- ▸Apps needing extremely lightweight bundle sizes
- ▸Web-first applications with minimal native features
- ▸Developers preferring full native platform SDKs for UI
Cheat Sheet
- ▸`ns create MyApp` - create project
- ▸`ns platform add android ios` - add platform
- ▸`ns plugin add <plugin-name>` - add plugin
- ▸`ns run android` - run on device/emulator
- ▸`ns build ios` - build for iOS
FAQ
- ▸Is NativeScript maintained?
- ▸Yes, actively maintained by Progress and community.
- ▸Can I use Angular or Vue?
- ▸Yes, NativeScript supports Angular, Vue, and plain TypeScript/JS.
- ▸Does it support native APIs?
- ▸Yes, directly without WebView.
- ▸Is it suitable for high-performance apps?
- ▸Yes, NativeScript renders real native UI components.
- ▸Can I deploy to both iOS and Android?
- ▸Yes, cross-platform deployment is supported.
30-Day Skill Plan
- ▸Week 1: Create projects and add platforms
- ▸Week 2: Learn core UI components and layout system
- ▸Week 3: Use plugins for camera, GPS, notifications
- ▸Week 4: Optimize performance and debug native code
- ▸Week 5: Deploy apps to stores and maintain plugins
Final Summary
- ▸NativeScript allows building truly native iOS and Android apps with one codebase.
- ▸Direct access to native APIs ensures real native performance.
- ▸Supports Angular, Vue, TypeScript, and JavaScript.
- ▸Ideal for enterprise apps, high-performance consumer apps, and rapid prototyping.
- ▸Offers a rich plugin ecosystem and CLI tools for building, testing, and deploying.
Project Structure
- ▸app/ - source code including components, styles, and logic
- ▸package.json - npm dependencies
- ▸node_modules/ - installed packages
- ▸platforms/ - platform-specific builds
- ▸hooks/ - build scripts and automation
Monetization
- ▸Enterprise internal apps
- ▸Consumer apps with cross-platform reach
- ▸Consulting for NativeScript projects
- ▸Plugin development for device features
- ▸Rapid deployment solutions
Productivity Tips
- ▸Leverage CLI commands for efficiency
- ▸Use plugins for native functionality
- ▸Test frequently on devices
- ▸Use Angular/Vue integration for consistent UI
- ▸Document code and project structure
Basic Concepts
- ▸Projects have `app/` folder for source code
- ▸`package.json` and `nsconfig.json` manage dependencies and config
- ▸Plugins provide access to native APIs
- ▸CLI commands handle builds, platforms, and live sync
- ▸Native UI components mapped directly from JavaScript/TypeScript