8000 nuxt hello page · javascriptit/examples-1@4940d16 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4940d16

Browse files
committed
nuxt hello page
1 parent e150c4f commit 4940d16

File tree

5 files changed

+36
-0
lines changed

5 files changed

+36
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
exports.install = function () {
2+
const reg = /^(?!\/api)[/A-Za-z0-9_.]*$/
3+
/*
4+
* Test url, if not start with '/api' then use nuxt middleware to handle the request
5+
* */
6+
F.route((url)=>{ return reg.test(url)}, nuxt, ['#nuxt'])
7+
F.file((url)=>{return reg.test(url.uri.path)}, nuxt, ['#nuxt'])
8+
}
9+
10+
function nuxt () {
11+
//this should not be execute
12+
throw new Error('nuxt middle ware not working')
13+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const Nuxt = require('nuxt')
2+
const options = require('../nuxt.config')
3+
const nuxt = new Nuxt(options)
4+
5+
nuxt.build().then(function () {
6+
F.middleware('nuxt', nuxt.render)
7+
})

nuxt-middleware/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
const options = {port: 8000, ip:'127.0.0.1'}
2+
require('total.js').http('debug',options)

nuxt-middleware/nuxt.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
srcDir: 'nuxt/'
3+
}

nuxt-middleware/nuxt/pages/index.vue

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<template>
2+
<div>
3+
<h3>Hello from Total.js and Nuxt.js</h3>
4+
</div>
5+
</template>
6+
<script>
7+
8+
</script>
9+
<style scoped>
10+
11+
</style>

0 commit comments

Comments
 (0)
0