vuejs router - 要求未定义 [英] vuejs router - Require is not defined

查看:348
本文介绍了vuejs router - 要求未定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力开始这个: https://github.com/vuejs/vue-router

I am trying to get started with this: https://github.com/vuejs/vue-router

我已经克隆了包裹,并按照说明进行构建:

I have cloned the package, and followed the instructions to build:

npm install
npm run build

但我收到了要求未定义错误开启:

But I am receiving a "Require is not defined" error on:

var Vue = require('vue')
var VueRouter = require('../src')

in /example/example.js

in /example/example.js

我已经安装了node和browserify ...不知道该怎么办。

I have installed node and browserify... Not sure what to do.

推荐答案

你有没有安装Browserify后完成以下操作?

Have you done the following after you installed Browserify?

1)使用命令将所有.js文件捆绑到一个文件中(例如'bundle.js'):

1) bundle all your .js files into one file (e.g. 'bundle.js') using command:

browserify example/example.js -o bundle.js

2)将'bundle.js'脚本放入.html文件中:

2) put 'bundle.js' script into your .html file:

<script src="bundle.js"></script>

重要提示:不要将'example.js'脚本放入.html文件中作为'bundle.js'已经包含了'example.js'文件中的所有内容。

Important: Do not put 'example.js' script into .html file as 'bundle.js' already includes everything from your 'example.js' file.

这篇关于vuejs router - 要求未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆