How to create a mobile app with Vue Native
Creating a mobile application using Vue Native is an effective way to achieve cross-platform development using Vue.js syntax combined with React Native; 2. First configure the development environment, install Node.js and Expo CLI, and create a project through the command npx create-react-native-app my-vue-app --template vue-native; 3. Enter the project directory and run npm start, scan the QR code through the Expo Go application to preview it on the mobile device; 4. Write .vue file components, use <template>, <script> and <style> structures, pay attention to lowercase React Native components such as view, text and button; 5. The style uses CSS-like writing but is limited to React Native's StyleSheet Model, only some Flexbox features are supported; 6. Event binding uses @on-event name syntax, such as @on-press instead of @click; 7. Form elements such as input boxes need to be manually bound, because there is no default v-model support; 8. Navigation can be implemented through integrated React Navigation, and its API needs to be called in the Vue component, or a community routing scheme is used; 9. After development is completed, use npx expo build:android or npx expo build:ios to generate production versions and publish them to the application store according to the Expo guide; 10. If you need to customize native modules, you can enter the naked workflow without Expo hosting mode, but the complexity is increased; in short, Vue Native is suitable for developers familiar with Vue to quickly build lightweight cross-platform applications, and its core is React Native, some Vue has limited functionality but is syntax-friendly, it is recommended to start with Expo templates for efficient iteration.
Creating a mobile app with Vue Native is a solid choice if you want to build cross-platform apps using Vue.js syntax and React Native under the hood. Vue Native lets you write Vue-style code while compiling it into native mobile components via React Native. Here's a practical guide to get you started.

Set Up Your Development Environment
Before you start coding, make sure your system is ready for React Native development, since Vue Native relies on it.
-
Install Node.js and npm
Make sure you have Node.js (v14 or higher) installed. You can check with:node -v
Install Expo CLI (Recommended)
Expo simplifies React Native setup and testing:npm install -g @expo/cli
Install Vue Native CLI
Although the originalvue-native-cli
is no longer actively maintained, the recommended way now is to use the Vue Native Expo template :npx create-react-native-app my-vue-app --template vue-native
Navigate to Project and Start
cd my-vue-app npm start
This will launch the Expo dev server. You can scan the QR code with the Expo Go app on your iOS or Android device to see your app.
Write Your First Vue Native Component
Vue Native uses .vue
files with <template>
, <script>
, and optional <style>
sections.
Example: App.vue
<template> <view class="container"> <text class="title">Hello from Vue Native!</text> <button title="Press Me" @on-press="handlePress" /> </view> </template> <script> export default { methods: { handlePress() { alert("Button pressed!"); } } } </script> <style> .container { flex: 1; justify-content: center; align-items: center; background-color: #f0f0f0; } .title { font-size: 24; color: #333; margin-bottom: 20; } </style>
Note: Vue Native uses React Native components (like
view
,text
,button
) in lowercase. Styling uses JavaScript objects, but in.vue
files, you can write CSS-like rules.
Key Differences from Web Vue
Since Vue Native runs on React Native, there are important differences:
- No HTML elements : Use React Native components (
view
,text
,image
,scroll-view
, etc.) - Styleling is limited to React Native's StyleSheet model : No full CSS. Flexbox works, but things like
float
,position: absolute
have limitations. - Event binding uses
@on-eventname
: eg,@on-press
instead of@click
- No
v-model
by default : You'll need to manually bind values usingv-bind
and event handlers
Example of input binding:
<template> <view class="container"> <text>{{ message }}</text> <text-input :value="inputText" @on-change-text="inputText = $event" placeholder="Type something" class="input" /> </view> </template> <script> export default { data() { return { inputText: "" }; }, computed: { message() { return this.inputText || "No input yet"; } } } </script>
Add Navigation
Vue Native works with React Navigation. You can set up navigation using the standard React Navigation setup, but call it from Vue components.
Install dependencies:
npm install @react-navigation/native @react-navigation/stack npm install react-native-screens react-native-safe-area-context
Create navigation containers in your main app file (may require some React syntax if mixing with Vue).
Alternatively, use Vue Native Router (community package) or manage routing manually with state and conditional rendering for simple apps.
Build and Deploy
Once your app is ready:
- Test on device using Expo Go during development.
- Create a production build :
npx expo build:android npx expo build:ios
- Follow Expo's guide to publish or submit to app stores.
Note: If you need custom native modules, you may need to eject from Expo (use the bare workflow), which adds complexity.
Creating a mobile app with Vue Native is straightforward if you already know Vue. It's not as mature as React Native or NativeScript-Vue, but it's a viable option for lightweight cross-platform apps using familiar syntax. Just remember: under the hood, it's React Native, so some Vue features are adapted or limited.
Basically, start with the Expo template, use Vue-style syntax with React Native components, and leverage Expo for fast iteration. That's the fastest path to a working app.
The above is the detailed content of How to create a mobile app with Vue Native. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Environment variable management is crucial in Vue projects and you need to choose the right way based on the build tool. 1. The VueCLI project uses the .env file with VUE_APP_ prefix, accessed through process.env.VUE_APP, such as .env.production; 2. The Vite project uses the VITE_ prefix, accessed through import.meta.env.VITE_, such as .env.staging; 3. Both support custom mode to load corresponding files, and the .env.local class file should be added to .gitignore; 4. Always avoid exposing sensitive information on the front end, provide .env.example for reference, and check it at runtime.

Install ApolloClient and related dependency packages and configure the client according to Vue2 or Vue3; 2. Provide client instances in Vue3 through provideApolloClient, and use VueApollo plug-in in Vue2; 3. Use the combined API of useQuery and useMutation to initiate queries and changes in components; 4. Use variables and refetch to achieve dynamic data acquisition and refresh, optional polling and updates; 5. Use loading and error state to optimize user experience, and combine Suspense or anti-shake to improve interaction fluency; 6. Add authentication information through HTTP link headers, and use caches, fragments and query files to organize and provide

Usecomputedpropertieswhenderivingreactivevaluesfordisplay,astheyarecachedandonlyre-evaluatewhendependencieschange;2.UsewatchforexecutingsideeffectslikeAPIcallsorupdatingstorageinresponsetodatachanges,sincewatchersreacttovaluechangesandsupportasyncope

TeleportinVue3allowsrenderingacomponent'stemplateinadifferentDOMlocationwhilepreservingitslogicalpositioninthecomponenttree;1.ItusesthecomponentwithatoattributespecifyingthetargetDOMnode,suchas"body"or"#modal-root";2.Theteleported

Functional components are used in Vue2 to create stateless, high-performance presentation components, suitable for scenarios that rely only on props. 1. To define functional:true, you need to set functional:true to receive props and context through the render function to return VNode. 2. Register and pass in props and events like normal components when used. 3. To handle slots, you need to get slots() and children from the context. Functional components are not suitable for scenarios where responsive data, lifecycle hooks, or v-models are required. Vue3 has removed the functional option and replaced it with functional writing or concise combination components. Performance optimization depends more on Comp

Create a mobile application using VueNative is an effective way to achieve cross-platform development using Vue.js syntax combined with ReactNative; 2. First configure the development environment, install Node.js and ExpoCLI, and create a project through the command npxcreate-react-native-appmy-vue-app--templatevue-native; 3. Enter the project directory and run npmstart, scan the QR code through the ExpoGo application to preview it on the mobile device; 4. Write the .vue file components, use and structure, and pay attention to using lowercase ReactNative components such as view, text and buttons in lowercase

Use Vite to create a Vue3 project that supports TypeScript; 2. Use defineComponent to provide type inference; 3. Use simplified code; 4. Use interfaces or types to define props; 5. Use type joint to correctly declare emits; 6. Use generics in composable functions; 7. Use InjectionKey to type provide/inject—through these steps, you can realize type-safe and maintainable Vue3 TypeScript applications, and finally build a powerful and extensible front-end project.

Installing Storybook can be done automatically through npxstorybook@latestinit, or manually install dependencies and configure .storybook/main.js and preview.js; 2. Write story files (such as Button.stories.js) to define different states of components, and use Template binding parameters to generate multiple instances; 3. Use Args and Controls to achieve dynamic attribute adjustments to improve interactive testing efficiency; 4. Integrate documents and stories through MDX files to enhance readability and collaboration; 5. It is recommended to co-locate story files with components, adopt CSF format, integrate Chromatic for visual regression testing, and use decoration
