Angular 6-Cordova-如何将当前的角度项目转换为基于Cordova的项目? [英] Angular 6 - Cordova - How to convert current angular project to cordova-based project?
问题描述
我有一个完全开发的angular 6项目,我想使用cordova和ionic将其构建到移动应用程序中,但是我不知道如何将项目转换为基于cordova的项目. cordova指令中显示的命令似乎创建了一个全新的空白项目,并且迁移该项目确实是不可行的.我到处搜寻,但没有发现提及此结果的结果.这里有没有人可以帮忙的?
I have a fully developed angular 6 project and I want to build it to mobile app using cordova and ionic, but I have no idea how to convert the project to cordova-based project. The command shown in cordova instruction seems to create a whole new blank project, and migrating the project would really be a no go. I've searched around but found nearly no result mentioning this. Are there any one here can help?
推荐答案
仅遵循 https://cordova.apache.org/docs/en/latest/guide/cli/.本指南创建一个空"应用程序.仅将应用程序的dist文件夹复制到cordova项目的www目录.您也可以使用Visual Studio 2017并创建一个空白的cordova项目.再次,将dist文件夹复制到www目录
It's only follow the instructions in https://cordova.apache.org/docs/en/latest/guide/cli/. This guide create an "empty" app. only copy dist folder of your app to the www directory of the cordova project. You can use Visual Studio 2017 too and create a blank cordova project. Again, copy your dist folder to the www directory
但是,在更改index.html之前,添加
But, before change your index.html adding the
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/index.js"></script>
如果直接使用科尔多瓦
或添加
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="scripts/platformOverrides.js">
如果您使用VisualStudio 2017
if you use VisualStudio 2017
在页面末尾(紧接在body close标签之前)
at end of your page (just before body close tag)
If you want to control the "back button" you can follow the instructions of Close angular modal and remain on same page on back button click
更新,对于Angular 8,您需要进行一些更改
Update for Angular 8 you need make some change
您需要从index.html中删除创建的"es-5",因此您的索引如下:
Your need remove from index.html the "es-5" created, so your index becomes like:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta name="format-detection" content="telephone=no">
<meta name="msapplication-tap-highlight" content="no">
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
<title>App title</title>
<!--IMPORTANT base href="./"--->
<base href="./">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link rel="stylesheet" href="styles.css">
</head>
<body>
<app-root></app-root>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="runtime-es2015.js"></script>
<script type="text/javascript" src="polyfills-es2015.js"></script>
<script type="text/javascript" src="scripts.js" defer></script>
<script type="text/javascript" src="main-es2015.js"></script>
</body>
</html>
注意:使用
ng build --prod=true --outputHashing=none --namedChunks=false --vendorChunk=false
构建应用程序
这篇关于Angular 6-Cordova-如何将当前的角度项目转换为基于Cordova的项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!