0

我想在本地运行Vue.js/System.js我最近得到的一个演示应用程序,以前从未使用System.js过(我不会......)

我只想运行这个演示,在切换到 webpack 之前......没有 npm 脚本(所以没有安装,没有运行开发)

我应该如何运行它以在我的本地浏览器中显示?跑步前有什么事情要做吗?(没有关于它的文档..)

demo
    app
      components
      About
      App
      ..
      index.js
    routes
      Home
      ...
      index.js
    style
      main.css
  assets
    home
      ...
    ...
  documentation
    ...
  libs
  favicon.ico
  index.html
  readme.html

更新

这是system.config

System.config({
    defaultJSExtensions: true
    , map: {
        'app': './app'
        , 'js': '/libs/js'
        , 'style': '/libs/css'
        , 'theme': '/app/theme'
        , 'babel': '/libs/js/babel-core'
        , 'components': '/app/components',
        'routes': '/app/routes',
    },
    transpiler: 'babel'
    , meta: {
        'js/*.js': {
            format: 'global'
        }
    }
});

System.import('/app/index.js');

index.html

<!doctype html>
<html class="no-js" lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="author" content="BelosTemas">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Test template</title>
    <link rel="shortcut icon" type="image/png" href="favicon.ico" />
    <link rel="stylesheet" href="./app/style/main.css" id="theme-stylesheet">
</head>

<body>
    <div id="app">
        <app></app>
    </div>
    <!-- system -->
    <script src="/libs/js/system.js"></script>
    <script src="/app/system.config.js"></script>
</body>
</html>

更新 2

我在 index.html 相对路径 (src='./) 中更改了脚本 src 路径,现在脚本文件位于.. 但它没有正确执行,CORS 相关问题..

错误:

system.js:5 Failed to load file:///app/index.js: Cross origin requests
are only supported for protocol schemes: http, data, chrome, 
chrome-extension, https.
4

1 回答 1

2

我解决了,安装了一个轻量级的网络服务器

npm install -g live-server

然后在控制台中,转到我的应用程序目录,我只是运行它

live-server

默认浏览器打开http://localhost:8080 奖励:热重载!

于 2018-01-16T10:04:01.860 回答