问题
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
I have installed node and browserify... Not sure what to do.
回答1:
Have you done the following after you installed Browserify?
1) bundle all your .js files into one file (e.g. 'bundle.js') using command:
browserify example/example.js -o bundle.js
2) put 'bundle.js' script into your .html file:
<script src="bundle.js"></script>
Important: Do not put 'example.js' script into .html file as 'bundle.js' already includes everything from your 'example.js' file.
来源:https://stackoverflow.com/questions/31658726/vuejs-router-require-is-not-defined