mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-23 14:15:13 +00:00
examples: Use process.server instead of isServer
This commit is contained in:
parent
262bffc35d
commit
23e1c3fd06
@ -7,8 +7,8 @@ module.exports = {
|
||||
app: 'app.[chunkhash].js' // default: nuxt.bundle.[chunkhash].js
|
||||
},
|
||||
vendor: ['lodash'],
|
||||
extend (config, { dev }) {
|
||||
if (dev) {
|
||||
extend (config, { isDev }) {
|
||||
if (isDev) {
|
||||
config.devtool = 'eval-source-map'
|
||||
}
|
||||
const urlLoader = config.module.rules.find((loader) => loader.loader === 'url-loader')
|
||||
|
@ -3,7 +3,7 @@ import VueI18n from 'vue-i18n'
|
||||
|
||||
Vue.use(VueI18n)
|
||||
|
||||
export default ({ app, isClient, store }) => {
|
||||
export default ({ app, store }) => {
|
||||
// Set i18n instance on app
|
||||
// This way we can use it in middleware and pages asyncData/fetch
|
||||
app.i18n = new VueI18n({
|
||||
|
@ -7,9 +7,9 @@
|
||||
|
||||
<script>
|
||||
export default {
|
||||
asyncData ({ isServer }) {
|
||||
asyncData () {
|
||||
return {
|
||||
name: (isServer ? 'server' : 'client')
|
||||
name: (process.server ? 'server' : 'client')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,14 +11,14 @@ export const getCookies = (str) => {
|
||||
** Executed by ~/.nuxt/index.js with context given
|
||||
** This method can be asynchronous
|
||||
*/
|
||||
export default ({ isServer, req }, inject) => {
|
||||
export default ({ req }, inject) => {
|
||||
// Inject `cookies` key
|
||||
// -> app.$cookies
|
||||
// -> this.$cookies in vue components
|
||||
// -> this.$cookies in store actions/mutations
|
||||
inject('cookies', new Vue({
|
||||
data: () => ({
|
||||
cookies: getCookies(isServer ? req.headers.cookie : document.cookie)
|
||||
cookies: getCookies(process.server ? req.headers.cookie : document.cookie)
|
||||
}),
|
||||
methods: {
|
||||
set(...args) {
|
||||
|
@ -7,9 +7,9 @@
|
||||
|
||||
<script>
|
||||
export default {
|
||||
asyncData ({ req, isServer }) {
|
||||
asyncData () {
|
||||
return {
|
||||
name: req ? 'server' : 'client'
|
||||
name: process.server ? 'server' : 'client'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user