chrisvfritz / vue-2.0-simple-routing-example Goto Github PK
View Code? Open in Web Editor NEWA simple example of routing with Vue 2.0 without using vue-router.
Home Page: http://vue-2-simple-routing-example.surge.sh/
A simple example of routing with Vue 2.0 without using vue-router.
Home Page: http://vue-2-simple-routing-example.surge.sh/
when I exuc
npm run build
throw a error
ERROR in build.js from UglifyJs
SyntaxError: Unexpected token: name (Vue) [./src/main.js:1,7]
That's 766 node modules installed when running the app...
To really get the most out of Page.js, it seems like we'd need the context within the Vue component itself. What's a good way to do this?
My best attempt so far is:
(src/main.js)
line 10: render (h) { return h(this.ViewComponent, { props: { context:this.context} }) }
line 15: page(route, (ctx) => { app.context = ctx; app.ViewComponent = Component })
(src/pages/Home.vue)
add before line 11: props: [ 'context' ]
(repeat for each page)
Not sure if this is a good practice or not, but it seems to work.
I set up the local instance as mentioned in the doc. But its not working at all. It doesn't through up any error in the console as well.
After npm run build
this is what's in the dist folder:
-a---- 20-12-2016 13:24 58065 build.js
-a---- 20-12-2016 13:24 475164 build.js.map
How do I serve this?
Saw this line and to the best of my knowledge, it doesn't do anything:
import routes from '../routes'
npm WARN deprecated [email protected]: We're super 😸 excited that you're trying to use ES2015 syntax, but instead of continuing yearly presets 😭 , we recommend using babel-preset-env: npm install babel-preset-env. preset-env without options will compile ES2015+ down to ES5. And by targeting specific browsers, Babel can do less work and you can ship native ES2015+ to users 😎 ! Also, we are in the process of releasing v7, so give http://babeljs.io/blog/2017/09/12/planning-for-7.0 a read and test it! Thanks so much for using Babel 🙏 , please give us a follow @babeljs for updates, join slack.babeljs.io for discussion and help support at opencollective.com/babel
Does this support route parameters?
I run npm install
now running npm run dev but i get an error
The npm-debug.log reads:
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/Cellar/node/7.4.0/bin/node',
1 verbose cli '/usr/local/bin/npm',
1 verbose cli 'run',
1 verbose cli 'dev' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'predev', 'dev', 'postdev' ]
5 info lifecycle vue-2.0-simple-routing-example@~predev: vue-2.0-simple-routing-example@
6 silly lifecycle vue-2.0-simple-routing-example@~predev: no script for predev, continuing
7 info lifecycle vue-2.0-simple-routing-example@~dev: vue-2.0-simple-routing-example@
8 verbose lifecycle vue-2.0-simple-routing-example@~dev: unsafe-perm in lifecycle true
9 verbose lifecycle vue-2.0-simple-routing-example@~dev: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/Users/mikeconnor/Documents/git repos/vue-2.0-simple-routing-example/node_modules/.bin:/usr/local/sbin:/usr/local/sbin:/Users/mikeconnor/.rbenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/MacGPG2/bin:/Users/mikeconnor/.rvm/bin
10 verbose lifecycle vue-2.0-simple-routing-example@~dev: CWD: /Users/mikeconnor/Documents/git repos/vue-2.0-simple-routing-example
11 silly lifecycle vue-2.0-simple-routing-example@~dev: Args: [ '-c', 'webpack-dev-server --inline --hot' ]
12 silly lifecycle vue-2.0-simple-routing-example@~dev: Returned: code: 1 signal: null
13 info lifecycle vue-2.0-simple-routing-example@~dev: Failed to exec dev script
14 verbose stack Error: vue-2.0-simple-routing-example@ dev: webpack-dev-server --inline --hot
14 verbose stack Exit status 1
14 verbose stack at EventEmitter. (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:279:16)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at EventEmitter.emit (events.js:191:7)
14 verbose stack at ChildProcess. (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:40:14)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at ChildProcess.emit (events.js:191:7)
14 verbose stack at maybeClose (internal/child_process.js:885:16)
14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
15 verbose pkgid vue-2.0-simple-routing-example@
16 verbose cwd /Users/mikeconnor/Documents/git repos/vue-2.0-simple-routing-example
17 error Darwin 16.3.0
18 error argv "/usr/local/Cellar/node/7.4.0/bin/node" "/usr/local/bin/npm" "run" "dev"
19 error node v7.4.0
20 error npm v4.1.1
21 error code ELIFECYCLE
22 error vue-2.0-simple-routing-example@ dev: webpack-dev-server --inline --hot
22 error Exit status 1
23 error Failed at the vue-2.0-simple-routing-example@ dev script 'webpack-dev-server --inline --hot'.
23 error Make sure you have the latest version of node.js and npm installed.
23 error If you do, this is most likely a problem with the vue-2.0-simple-routing-example package,
23 error not with npm itself.
23 error Tell the author that this fails on your system:
23 error webpack-dev-server --inline --hot
23 error You can get information on how to open an issue for this project with:
23 error npm bugs vue-2.0-simple-routing-example
23 error Or if that isn't available, you can get their info via:
23 error npm owner ls vue-2.0-simple-routing-example
23 error There is likely additional logging output above.
24 verbose exit [ 1, true ]
Mikes-MacBook:vue-2.0-simple-routing-example mikeconnor$
Home Coach Mark 1
when i execute 'npm run build', and start a server in root directory,the page is ok, but when i refresh the browser, the page is wrong with Cannot GET /about
when i was start in nginx server
http://localhost:9999/index.html
console say:
Failed to load resource: the server responded with a status of 404 (Not Found) build.js
where was wrong i set??
Hey, thank you for this bare-bones setup.
I was wondering if you've ever thought about Scroll position & keep alive.
I cloned this repo and added more content to each page and I've make the header fixed with CSS.
It looks like when I click on a link the new page loads, but the scroll is maintained, but the default behavior should be to load the new page with scroll position at zero.
I will do more research in the weekend for this, but I would like to know if you already have any insights about scroll position and keep-alive without the vuerouter and if you are willing to share with us.
Thank you,
Adrian
i pass the params like blew:
and find that the params is empty when i us js to get it:
this.$route.params
//there's no id in the params object
Hi, nice work. One issue:
Watching browser history in Chrome all entries are pointing to the home url. This isn't a reflection of the reality. What can I (or you?) do to make that right?
this is great example but 404 works fine when http://app.dev/routeNotFound
but when we try to use something like this: http://app.dev/some/page/
then it's collapse.
please update this code.
Thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.