vue-web-native

Vue+Web+Native
授权协议 Readme
开发语言 JavaScript
所属分类 Web应用开发、 常用JavaScript包
软件类型 开源软件
地区 不详
投 递 者 楚意
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

Vue+Web+Native

THIS PROJECT IS UNDER DEVELOPMENT AND STILL AT AN EARLY STAGE.

Vue+Web+Native is a boilerplate based on Vue and Nativescript that allows for simultaneous development of web and native applications.

Contents

Before we start

Vue+Web+Native uses vue-native-web to compile all your files. These are the main features.

  • Latest version of vue-loader
  • Latest version of nativescript
  • CSS/SCSS/SASS
  • Hot reload (for web only)
  • Vue single-file components
  • Extract CSS
  • Target either native or web
  • Target either iOS, Android or web
  • Custom blocks in single-file components

Installation

If you want to try it out Vue+Web+Native is set up with default values.

git clone https://github.com/yassipad/vue-web-native.git
cd vue-web-native

Then you simply need to install the dependencies.

npm install

or

yarn install

And you're set!

Configuration

There are a few things that are necessary to be able to use this boilerplate. By default, everything is already in place, so you should not run into any issues.

First, you need to make sure that your root folder contains an App_Resources folder with all the files required by your native app (e.g. splashscreens, configuration...).

For iOS, you should also specifiy your DEVELOPMENT_TEAM in the App_Resources/iOS/build.xconfig file.

Second, you also need to make sure that your src folder contains an assets folder, which will contain all your assets for both native and web apps.

Third, you will notice that the package.json file contains this:"nativescript" : { "id": "org.vuenativeweb.app" }. This key is asbolutely required as this corresponds to your App Id. This will automatically get copied into the right places for you, you are free to change it but do not remove it.

Usage

Commands

These are the available commands.

build: build iOS, Android and web apps in production mode.
build:native: build iOS and Android apps in production mode.
build:web: build web app in production mode.
build:android: build android app in production mode.
build:ios: build iOS app in production mode.

watch: build iOS, Android and web apps in development mode and watches for changes.
watch:native: build iOS and Android apps in development mode and watches for changes.
watch:web: build web app in development mode and watches for changes.
watch:android: build Android app in development mode and watches for changes.
watch:ios: build iOS app in development mode and watches for changes.

debug: build iOS, Android and web apps in development mode with --debug option for native apps.
debug:native: build iOS and Android apps in development mode with --debug option.
debug:android: build Android app in development mode with --debug option.
debug:ios: build iOS app in development mode with --debug option.

hot: build web app in development mode with hot reload.
dev: build web app in development mode.

In single-file components

In single-file components, you can now add two attributes to your blocks: native or web. This attribute will tell webpack which part of this file to compile to which file.

Example:

<template web>
    <h1>Bonjour sur {{platform}}!</h1>
</template>

<template native>
    <Label class="h1">Bonjour sur {{platform}}!</Label>
</template>

This also works on <script> and <style>. For the moment, custom blocks are not supported. And of course, you can still add all the other attributes you are used to.

Example:

<style lang="sass" native scoped>
Page
    background-color: black
</style>

If you do not add a specific attribute, the block will be compiled to both targets (native and web).

Example:

<template web>
    <h1 class="title">{{message}}</h1>
</template>

<template native>
    <Label class="title">{{message}}</Label>
</template>

<script>
export default { 
	data () {
		return {
			message: 'Salut' 
		}
	}
}
</script>

<style lang="css" scoped>
.title {
	color: red;
}
</style>

<style lang="sass" native>
.title
	font-size: 30px
</style>

In all other files

In other files you can also tell webpack which part of said file are meant to be compiled for which target bu using two markers: /*--@web--*/ and /*--@native--*/.

Example:

import Vue from 'vue'
import App from './components/App'

const app = new Vue({
	render: h => h(App)
})

/*--@web--*/
app.$mount('#app')
/*--@web--*/

/*--@native--*/
app.$start()
/*--@native--*/

This can also be useful to only import the files you want.

Example:

/*--@native--*/
import stripe from 'nativescript-stripe'
/*--@native--*/

/*--@web--*/
import stripe from 'stripe'
/*--@web--*/

stripe.doSomething()

Add nativescript packages

You can add nativescript packages as usual simply by running:

npm install nativescript-package

or

yarn add nativescript-package

Webpack will then automatically detect whether your package is meant for nativescript or not and add it to the dependencies of your native app if it is.

License

MIT

Contributions

As stated earlier, this project is still in a very early development stage so any contribution is welcome at this point.

  • Vue native修饰符 概述 在我们需要监听一个组件的原生事件时,必须给对应的事件加上.native修饰符,才能进行监听。 使用 <template> <div id="app"> <h1>基本程序已运行</h1> <MyButton @click.native="buttonClicked">自定义组件按钮</MyButton> </div> </template>

  • 一、React Native简介: 1、React Native采用JavaScript 框架,将 React 基础抽象组件渲染为原生平台UI组件,像View, Text 以及 Image等,可直接映射渲染为对应平台的原生UI组件 2、通过 React 的声明式组件机制和 JavaScript 代码,现有的原生代码和api可以完美地封装嵌合到 React 组件中 3.、React Native创建

  • Vue.js不支持IE 8及以下版本,因为它使用了IE 8无法模拟的ECMAScript 5特性,但它支持所有兼容ECMAScript 5的浏览器。 一、Vue.js的安装 Vue的运行是依赖于Node的npm的管理工具来实现的,所以在搭建Vue的开发环境之前,需要安装Node运行环境。 1、类似于Bootstrap或jQuery,直接通过HTML文件中的标签引用。 Vue.js提供了相关的CDN

  • .native是什么? .native - 监听组件根元素的原生事件。  主要是给自定义的组件添加原生事件。 例子  给普通的标签加事件,然后加native是无效的 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> <di

  • What is NativeScript? NativeScript 是一个可以让你用Typescript或JavaScript开发原生ios或android app的开源框架 在我写下这篇文章的时候,github上的star数为12k。 What is Vue.js? Vue是一套用于构建用户界面的渐进式框架。在我写下这篇文章时,github上star数为85k。 What is NativeS

  • Vue与Web Components Web Components是一组Web原生API的总称,允许开发人员创建可重用的组件。 我们认为Vue和Web Components大体上是互补的技术。Vue能很好的解析和创建自定义元素。不论是在将自定义元素正和岛已有的Vue应用中,还是使用Vue构建和分发自定义元素,你都能获得很好的支持。 在Vue中使用自定义元素 Vue在Custom Elements

  • 有时发现用一些第三方的组件库时,例如一个封装好的button按钮,绑定点击事件却没有任何作用,这时便需要加 .native 原因: v-on 是对 Vue 的事件体系封装后的 API 接口,官方文档中指出Vue 使用的是一套自己的事件传递机制,如 @click 等事件是经过 Vue 封装的。所以在一些实际上处理 DOM 原生事件的场合需要添加额外的标识符。 而.native就是给组件绑定原生事件采

 相关资料
  • vue-web-extension ⚠️ This README is for the master version of the preset. If you use the v1 of this boilerplate with Vue-CLI 2 support, please see v1 branch. This Vue CLI preset allows you to quickly

  • vue-web-component-wrapper 是一个使用 Vue 来开发 Web Components 的 JavaScript 库,支持大部分常用的 Vue API。 import Vue from 'vue'import wrap from '@vue/web-component-wrapper'const Component = { // any component options}

  • 我想在中实现下面的布局。是否有任何插件可用,通过它我可以设计布局像这样,它将工作

  • JavaScript旨在在单线程环境中运行,这意味着多个脚本无法同时运行。 考虑一种情况,您需要处理UI事件,查询和处理大量API数据以及操作DOM。

  • 万维网联盟(W3C)推出的Web RTC。 它支持用于语音呼叫,视频聊天和P2P文件共享的浏览器到浏览器应用程序。 如果你想试试? 适用于Chrome,Opera和Firefox的网络RTC。 一个好的起点是这里简单的视频聊天应用程序。 Web RTC实现了三个API,如下所示 - MediaStream - 访问用户的摄像头和麦克风。 RTCPeerConnection - 访问音频或视频通话设

  • Cross-origin resource sharing (CORS)是一种允许来自Web浏览器中其他域的受限资源的机制。 假设,如果你点击html5演示部分中的HTML5- video player 。 它会要求相机许可。 如果用户允许该权限,则只有它会打开相机,否则它不会打开相机用于Web应用程序。 发出CORS请求 这里Chrome,Firefox,Opera和Safari都使用XMLHt