Using Nuxt Site as a template
I'm getting started with nuxt, and vue. I want to create a simple site using vue and then turn it into a static site using :
nuxt generate
I've been able to do this using nuxt and vuetify (you can see this at https://github.com/kc1/nuxt4 ).
Is there a way to use this nuxt project as a template and perform a 'find and replace' with a file to produce an individualized website ?
As an example. The toolbar component is:
<template>
<v-toolbar color="indigo" dark>
<v-toolbar-side-icon></v-toolbar-side-icon>
<v-toolbar-title class="white--text">Title</v-toolbar-title>
<v-spacer></v-spacer>
<v-toolbar-items class="hidden-sm-and-down">
<v-btn flat>Link One</v-btn>
<v-btn flat>Link Two</v-btn>
<v-btn flat>Link Three</v-btn>
</v-toolbar-items>
</v-toolbar>
</template>
Is there a way to replace:
Title - > My project
Link One -> Home
Link Two -> About
Link Three -> Contact
Either before or after generating it as a static site?
EDIT:
following the https://nuxtjs.org/guide/vuex-store page for nuxt 2.34, In /store/store.js I Placed:
export const state = () => ({
'toolbarActions' : [ 'My project', 'Home', 'About', 'Contact' ]
})
I'm still getting:
ERROR [Vue warn]: data functions should return an object: 20:59:31
https://vuejs.org/v2/guide/components.html#data-Must-Be-a-Function
found in
---> <Menu> at components/menu.vue
<Default> at layouts/default.vue
<Root>
ERROR [Vue warn]: Error in render: "TypeError: Cannot use 'in' operator to search for 'toolbarActions' in undefined" 20:59:31
found in
---> <Menu> at components/menu.vue
<Default> at layouts/default.vue
<Root>
How can I fix this?
EDIT2:
<template>
<v-toolbar color="indigo" dark>
<v-toolbar-side-icon></v-toolbar-side-icon>
<v-toolbar-title class="white--text">Title</v-toolbar-title>
<v-spacer></v-spacer>
<v-toolbar-items class="hidden-sm-and-down">
<v-btn flat v-for="action in toolbarActions" :key="action">{{action}}</v-btn>
<!-- <v-btn flat v-for="action in toolbarActions">{{action}}</v-btn> -->
<!-- <v-btn flat>Link One</v-btn>
<v-btn flat>Link Two</v-btn>
<v-btn flat>Link Three</v-btn> -->
</v-toolbar-items>
</v-toolbar>
</template>
// import toolbarActions from '~/store/store.js'
export default {
computed: {
toolbarActions() {
return this.$store.getters.loadedPosts
.....
Now I'm seeing:
javascript vue.js nuxt
add a comment |
I'm getting started with nuxt, and vue. I want to create a simple site using vue and then turn it into a static site using :
nuxt generate
I've been able to do this using nuxt and vuetify (you can see this at https://github.com/kc1/nuxt4 ).
Is there a way to use this nuxt project as a template and perform a 'find and replace' with a file to produce an individualized website ?
As an example. The toolbar component is:
<template>
<v-toolbar color="indigo" dark>
<v-toolbar-side-icon></v-toolbar-side-icon>
<v-toolbar-title class="white--text">Title</v-toolbar-title>
<v-spacer></v-spacer>
<v-toolbar-items class="hidden-sm-and-down">
<v-btn flat>Link One</v-btn>
<v-btn flat>Link Two</v-btn>
<v-btn flat>Link Three</v-btn>
</v-toolbar-items>
</v-toolbar>
</template>
Is there a way to replace:
Title - > My project
Link One -> Home
Link Two -> About
Link Three -> Contact
Either before or after generating it as a static site?
EDIT:
following the https://nuxtjs.org/guide/vuex-store page for nuxt 2.34, In /store/store.js I Placed:
export const state = () => ({
'toolbarActions' : [ 'My project', 'Home', 'About', 'Contact' ]
})
I'm still getting:
ERROR [Vue warn]: data functions should return an object: 20:59:31
https://vuejs.org/v2/guide/components.html#data-Must-Be-a-Function
found in
---> <Menu> at components/menu.vue
<Default> at layouts/default.vue
<Root>
ERROR [Vue warn]: Error in render: "TypeError: Cannot use 'in' operator to search for 'toolbarActions' in undefined" 20:59:31
found in
---> <Menu> at components/menu.vue
<Default> at layouts/default.vue
<Root>
How can I fix this?
EDIT2:
<template>
<v-toolbar color="indigo" dark>
<v-toolbar-side-icon></v-toolbar-side-icon>
<v-toolbar-title class="white--text">Title</v-toolbar-title>
<v-spacer></v-spacer>
<v-toolbar-items class="hidden-sm-and-down">
<v-btn flat v-for="action in toolbarActions" :key="action">{{action}}</v-btn>
<!-- <v-btn flat v-for="action in toolbarActions">{{action}}</v-btn> -->
<!-- <v-btn flat>Link One</v-btn>
<v-btn flat>Link Two</v-btn>
<v-btn flat>Link Three</v-btn> -->
</v-toolbar-items>
</v-toolbar>
</template>
// import toolbarActions from '~/store/store.js'
export default {
computed: {
toolbarActions() {
return this.$store.getters.loadedPosts
.....
Now I'm seeing:
javascript vue.js nuxt
add a comment |
I'm getting started with nuxt, and vue. I want to create a simple site using vue and then turn it into a static site using :
nuxt generate
I've been able to do this using nuxt and vuetify (you can see this at https://github.com/kc1/nuxt4 ).
Is there a way to use this nuxt project as a template and perform a 'find and replace' with a file to produce an individualized website ?
As an example. The toolbar component is:
<template>
<v-toolbar color="indigo" dark>
<v-toolbar-side-icon></v-toolbar-side-icon>
<v-toolbar-title class="white--text">Title</v-toolbar-title>
<v-spacer></v-spacer>
<v-toolbar-items class="hidden-sm-and-down">
<v-btn flat>Link One</v-btn>
<v-btn flat>Link Two</v-btn>
<v-btn flat>Link Three</v-btn>
</v-toolbar-items>
</v-toolbar>
</template>
Is there a way to replace:
Title - > My project
Link One -> Home
Link Two -> About
Link Three -> Contact
Either before or after generating it as a static site?
EDIT:
following the https://nuxtjs.org/guide/vuex-store page for nuxt 2.34, In /store/store.js I Placed:
export const state = () => ({
'toolbarActions' : [ 'My project', 'Home', 'About', 'Contact' ]
})
I'm still getting:
ERROR [Vue warn]: data functions should return an object: 20:59:31
https://vuejs.org/v2/guide/components.html#data-Must-Be-a-Function
found in
---> <Menu> at components/menu.vue
<Default> at layouts/default.vue
<Root>
ERROR [Vue warn]: Error in render: "TypeError: Cannot use 'in' operator to search for 'toolbarActions' in undefined" 20:59:31
found in
---> <Menu> at components/menu.vue
<Default> at layouts/default.vue
<Root>
How can I fix this?
EDIT2:
<template>
<v-toolbar color="indigo" dark>
<v-toolbar-side-icon></v-toolbar-side-icon>
<v-toolbar-title class="white--text">Title</v-toolbar-title>
<v-spacer></v-spacer>
<v-toolbar-items class="hidden-sm-and-down">
<v-btn flat v-for="action in toolbarActions" :key="action">{{action}}</v-btn>
<!-- <v-btn flat v-for="action in toolbarActions">{{action}}</v-btn> -->
<!-- <v-btn flat>Link One</v-btn>
<v-btn flat>Link Two</v-btn>
<v-btn flat>Link Three</v-btn> -->
</v-toolbar-items>
</v-toolbar>
</template>
// import toolbarActions from '~/store/store.js'
export default {
computed: {
toolbarActions() {
return this.$store.getters.loadedPosts
.....
Now I'm seeing:
javascript vue.js nuxt
I'm getting started with nuxt, and vue. I want to create a simple site using vue and then turn it into a static site using :
nuxt generate
I've been able to do this using nuxt and vuetify (you can see this at https://github.com/kc1/nuxt4 ).
Is there a way to use this nuxt project as a template and perform a 'find and replace' with a file to produce an individualized website ?
As an example. The toolbar component is:
<template>
<v-toolbar color="indigo" dark>
<v-toolbar-side-icon></v-toolbar-side-icon>
<v-toolbar-title class="white--text">Title</v-toolbar-title>
<v-spacer></v-spacer>
<v-toolbar-items class="hidden-sm-and-down">
<v-btn flat>Link One</v-btn>
<v-btn flat>Link Two</v-btn>
<v-btn flat>Link Three</v-btn>
</v-toolbar-items>
</v-toolbar>
</template>
Is there a way to replace:
Title - > My project
Link One -> Home
Link Two -> About
Link Three -> Contact
Either before or after generating it as a static site?
EDIT:
following the https://nuxtjs.org/guide/vuex-store page for nuxt 2.34, In /store/store.js I Placed:
export const state = () => ({
'toolbarActions' : [ 'My project', 'Home', 'About', 'Contact' ]
})
I'm still getting:
ERROR [Vue warn]: data functions should return an object: 20:59:31
https://vuejs.org/v2/guide/components.html#data-Must-Be-a-Function
found in
---> <Menu> at components/menu.vue
<Default> at layouts/default.vue
<Root>
ERROR [Vue warn]: Error in render: "TypeError: Cannot use 'in' operator to search for 'toolbarActions' in undefined" 20:59:31
found in
---> <Menu> at components/menu.vue
<Default> at layouts/default.vue
<Root>
How can I fix this?
EDIT2:
<template>
<v-toolbar color="indigo" dark>
<v-toolbar-side-icon></v-toolbar-side-icon>
<v-toolbar-title class="white--text">Title</v-toolbar-title>
<v-spacer></v-spacer>
<v-toolbar-items class="hidden-sm-and-down">
<v-btn flat v-for="action in toolbarActions" :key="action">{{action}}</v-btn>
<!-- <v-btn flat v-for="action in toolbarActions">{{action}}</v-btn> -->
<!-- <v-btn flat>Link One</v-btn>
<v-btn flat>Link Two</v-btn>
<v-btn flat>Link Three</v-btn> -->
</v-toolbar-items>
</v-toolbar>
</template>
// import toolbarActions from '~/store/store.js'
export default {
computed: {
toolbarActions() {
return this.$store.getters.loadedPosts
.....
Now I'm seeing:
javascript vue.js nuxt
javascript vue.js nuxt
edited Dec 30 '18 at 15:14
user61629
asked Dec 29 '18 at 19:07
user61629user61629
8,82935131263
8,82935131263
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
Use Vuex to acompplish that.
create a file in store : /store/store.js
in there.
const store = new Vuex.Store({
state: {
toolbarActions : [ 'My project', 'Home', 'About', 'Contact' ]
}
})
in your component
<template>
...
<v-toolbar-items class="hidden-sm-and-down">
<v-btn flat v-for="action in toolbarActions">{{action}}</v-btn>
</v-toolbar-items>
...
</template>
export default {
computed: {
toolbarActions() {
return this.$store.getters.loadedPosts
}
}
}
This will give you insight of how Vuex works at the beggining.
Edited
Use the computed property instead. Let me know.
Edited 2
new Vue({
el: '#app',
computed: {
toolbarActions: function() {
return [ 'My project', 'Home', 'About', 'Contact' ]
}
}
})
<script src="https://cdn.jsdelivr.net/npm/vue@2.5.21/dist/vue.js"></script>
<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/vuex/3.0.1/vuex.js"></script>-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/vuetify/1.3.15/vuetify.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/vuetify/1.3.15/vuetify.css" />
<div id="app">
<v-toolbar color="indigo" dark>
<v-toolbar-side-icon></v-toolbar-side-icon>
<v-toolbar-title class="white--text">Title</v-toolbar-title>
<v-spacer></v-spacer>
<v-toolbar-items class="hidden-sm-and-down">
<v-btn flat v-for="action in toolbarActions" :key="action">{{action}}</v-btn>
<!-- <v-btn flat v-for="action in toolbarActions">{{action}}</v-btn> -->
<!-- <v-btn flat>Link One</v-btn>
<v-btn flat>Link Two</v-btn>
<v-btn flat>Link Three</v-btn> -->
</v-toolbar-items>
</v-toolbar>
</div>
P.D.: <v-toolbar-items class="hidden-sm-and-down">
are hidden the buttons in small devices.
Once clicked on run snippet, click in fullpage to see it working.
1
Bloody hell, this part of code is totally against all rules in documentation. Dont ever do this!data: function() { toolbarActions: this.$store.toolbarActions }
– webmint
Dec 30 '18 at 1:51
I'm running into a number of errors including ' Cannot use 'in' operator to search for 'toolbarActions' in undefined '. Taking a look at nuxtjs.org/guide/vuex-store, I'm assuming that the problem is with the vux store. I tried changing to the edit above.
– user61629
Dec 30 '18 at 2:05
@webmint i fix it by using computed property. This is more suitable for this escenario.
– Yoarthur
Dec 30 '18 at 2:34
1
@Yoarthur Yes, and also what is better to use mapGetters vuex helper.
– webmint
Dec 30 '18 at 14:22
@Yoarthur , please check my edit above
– user61629
Dec 30 '18 at 15:50
|
show 5 more comments
Read about ENV variables.
Also i would suggest u to create js file with values, add there export and use this file variables in nuxt components.
Another variant could be using Vuex store. U can create there for example module mainMeny and define there number of links, titles, and urls.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53972567%2fusing-nuxt-site-as-a-template%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Use Vuex to acompplish that.
create a file in store : /store/store.js
in there.
const store = new Vuex.Store({
state: {
toolbarActions : [ 'My project', 'Home', 'About', 'Contact' ]
}
})
in your component
<template>
...
<v-toolbar-items class="hidden-sm-and-down">
<v-btn flat v-for="action in toolbarActions">{{action}}</v-btn>
</v-toolbar-items>
...
</template>
export default {
computed: {
toolbarActions() {
return this.$store.getters.loadedPosts
}
}
}
This will give you insight of how Vuex works at the beggining.
Edited
Use the computed property instead. Let me know.
Edited 2
new Vue({
el: '#app',
computed: {
toolbarActions: function() {
return [ 'My project', 'Home', 'About', 'Contact' ]
}
}
})
<script src="https://cdn.jsdelivr.net/npm/vue@2.5.21/dist/vue.js"></script>
<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/vuex/3.0.1/vuex.js"></script>-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/vuetify/1.3.15/vuetify.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/vuetify/1.3.15/vuetify.css" />
<div id="app">
<v-toolbar color="indigo" dark>
<v-toolbar-side-icon></v-toolbar-side-icon>
<v-toolbar-title class="white--text">Title</v-toolbar-title>
<v-spacer></v-spacer>
<v-toolbar-items class="hidden-sm-and-down">
<v-btn flat v-for="action in toolbarActions" :key="action">{{action}}</v-btn>
<!-- <v-btn flat v-for="action in toolbarActions">{{action}}</v-btn> -->
<!-- <v-btn flat>Link One</v-btn>
<v-btn flat>Link Two</v-btn>
<v-btn flat>Link Three</v-btn> -->
</v-toolbar-items>
</v-toolbar>
</div>
P.D.: <v-toolbar-items class="hidden-sm-and-down">
are hidden the buttons in small devices.
Once clicked on run snippet, click in fullpage to see it working.
1
Bloody hell, this part of code is totally against all rules in documentation. Dont ever do this!data: function() { toolbarActions: this.$store.toolbarActions }
– webmint
Dec 30 '18 at 1:51
I'm running into a number of errors including ' Cannot use 'in' operator to search for 'toolbarActions' in undefined '. Taking a look at nuxtjs.org/guide/vuex-store, I'm assuming that the problem is with the vux store. I tried changing to the edit above.
– user61629
Dec 30 '18 at 2:05
@webmint i fix it by using computed property. This is more suitable for this escenario.
– Yoarthur
Dec 30 '18 at 2:34
1
@Yoarthur Yes, and also what is better to use mapGetters vuex helper.
– webmint
Dec 30 '18 at 14:22
@Yoarthur , please check my edit above
– user61629
Dec 30 '18 at 15:50
|
show 5 more comments
Use Vuex to acompplish that.
create a file in store : /store/store.js
in there.
const store = new Vuex.Store({
state: {
toolbarActions : [ 'My project', 'Home', 'About', 'Contact' ]
}
})
in your component
<template>
...
<v-toolbar-items class="hidden-sm-and-down">
<v-btn flat v-for="action in toolbarActions">{{action}}</v-btn>
</v-toolbar-items>
...
</template>
export default {
computed: {
toolbarActions() {
return this.$store.getters.loadedPosts
}
}
}
This will give you insight of how Vuex works at the beggining.
Edited
Use the computed property instead. Let me know.
Edited 2
new Vue({
el: '#app',
computed: {
toolbarActions: function() {
return [ 'My project', 'Home', 'About', 'Contact' ]
}
}
})
<script src="https://cdn.jsdelivr.net/npm/vue@2.5.21/dist/vue.js"></script>
<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/vuex/3.0.1/vuex.js"></script>-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/vuetify/1.3.15/vuetify.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/vuetify/1.3.15/vuetify.css" />
<div id="app">
<v-toolbar color="indigo" dark>
<v-toolbar-side-icon></v-toolbar-side-icon>
<v-toolbar-title class="white--text">Title</v-toolbar-title>
<v-spacer></v-spacer>
<v-toolbar-items class="hidden-sm-and-down">
<v-btn flat v-for="action in toolbarActions" :key="action">{{action}}</v-btn>
<!-- <v-btn flat v-for="action in toolbarActions">{{action}}</v-btn> -->
<!-- <v-btn flat>Link One</v-btn>
<v-btn flat>Link Two</v-btn>
<v-btn flat>Link Three</v-btn> -->
</v-toolbar-items>
</v-toolbar>
</div>
P.D.: <v-toolbar-items class="hidden-sm-and-down">
are hidden the buttons in small devices.
Once clicked on run snippet, click in fullpage to see it working.
1
Bloody hell, this part of code is totally against all rules in documentation. Dont ever do this!data: function() { toolbarActions: this.$store.toolbarActions }
– webmint
Dec 30 '18 at 1:51
I'm running into a number of errors including ' Cannot use 'in' operator to search for 'toolbarActions' in undefined '. Taking a look at nuxtjs.org/guide/vuex-store, I'm assuming that the problem is with the vux store. I tried changing to the edit above.
– user61629
Dec 30 '18 at 2:05
@webmint i fix it by using computed property. This is more suitable for this escenario.
– Yoarthur
Dec 30 '18 at 2:34
1
@Yoarthur Yes, and also what is better to use mapGetters vuex helper.
– webmint
Dec 30 '18 at 14:22
@Yoarthur , please check my edit above
– user61629
Dec 30 '18 at 15:50
|
show 5 more comments
Use Vuex to acompplish that.
create a file in store : /store/store.js
in there.
const store = new Vuex.Store({
state: {
toolbarActions : [ 'My project', 'Home', 'About', 'Contact' ]
}
})
in your component
<template>
...
<v-toolbar-items class="hidden-sm-and-down">
<v-btn flat v-for="action in toolbarActions">{{action}}</v-btn>
</v-toolbar-items>
...
</template>
export default {
computed: {
toolbarActions() {
return this.$store.getters.loadedPosts
}
}
}
This will give you insight of how Vuex works at the beggining.
Edited
Use the computed property instead. Let me know.
Edited 2
new Vue({
el: '#app',
computed: {
toolbarActions: function() {
return [ 'My project', 'Home', 'About', 'Contact' ]
}
}
})
<script src="https://cdn.jsdelivr.net/npm/vue@2.5.21/dist/vue.js"></script>
<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/vuex/3.0.1/vuex.js"></script>-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/vuetify/1.3.15/vuetify.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/vuetify/1.3.15/vuetify.css" />
<div id="app">
<v-toolbar color="indigo" dark>
<v-toolbar-side-icon></v-toolbar-side-icon>
<v-toolbar-title class="white--text">Title</v-toolbar-title>
<v-spacer></v-spacer>
<v-toolbar-items class="hidden-sm-and-down">
<v-btn flat v-for="action in toolbarActions" :key="action">{{action}}</v-btn>
<!-- <v-btn flat v-for="action in toolbarActions">{{action}}</v-btn> -->
<!-- <v-btn flat>Link One</v-btn>
<v-btn flat>Link Two</v-btn>
<v-btn flat>Link Three</v-btn> -->
</v-toolbar-items>
</v-toolbar>
</div>
P.D.: <v-toolbar-items class="hidden-sm-and-down">
are hidden the buttons in small devices.
Once clicked on run snippet, click in fullpage to see it working.
Use Vuex to acompplish that.
create a file in store : /store/store.js
in there.
const store = new Vuex.Store({
state: {
toolbarActions : [ 'My project', 'Home', 'About', 'Contact' ]
}
})
in your component
<template>
...
<v-toolbar-items class="hidden-sm-and-down">
<v-btn flat v-for="action in toolbarActions">{{action}}</v-btn>
</v-toolbar-items>
...
</template>
export default {
computed: {
toolbarActions() {
return this.$store.getters.loadedPosts
}
}
}
This will give you insight of how Vuex works at the beggining.
Edited
Use the computed property instead. Let me know.
Edited 2
new Vue({
el: '#app',
computed: {
toolbarActions: function() {
return [ 'My project', 'Home', 'About', 'Contact' ]
}
}
})
<script src="https://cdn.jsdelivr.net/npm/vue@2.5.21/dist/vue.js"></script>
<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/vuex/3.0.1/vuex.js"></script>-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/vuetify/1.3.15/vuetify.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/vuetify/1.3.15/vuetify.css" />
<div id="app">
<v-toolbar color="indigo" dark>
<v-toolbar-side-icon></v-toolbar-side-icon>
<v-toolbar-title class="white--text">Title</v-toolbar-title>
<v-spacer></v-spacer>
<v-toolbar-items class="hidden-sm-and-down">
<v-btn flat v-for="action in toolbarActions" :key="action">{{action}}</v-btn>
<!-- <v-btn flat v-for="action in toolbarActions">{{action}}</v-btn> -->
<!-- <v-btn flat>Link One</v-btn>
<v-btn flat>Link Two</v-btn>
<v-btn flat>Link Three</v-btn> -->
</v-toolbar-items>
</v-toolbar>
</div>
P.D.: <v-toolbar-items class="hidden-sm-and-down">
are hidden the buttons in small devices.
Once clicked on run snippet, click in fullpage to see it working.
new Vue({
el: '#app',
computed: {
toolbarActions: function() {
return [ 'My project', 'Home', 'About', 'Contact' ]
}
}
})
<script src="https://cdn.jsdelivr.net/npm/vue@2.5.21/dist/vue.js"></script>
<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/vuex/3.0.1/vuex.js"></script>-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/vuetify/1.3.15/vuetify.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/vuetify/1.3.15/vuetify.css" />
<div id="app">
<v-toolbar color="indigo" dark>
<v-toolbar-side-icon></v-toolbar-side-icon>
<v-toolbar-title class="white--text">Title</v-toolbar-title>
<v-spacer></v-spacer>
<v-toolbar-items class="hidden-sm-and-down">
<v-btn flat v-for="action in toolbarActions" :key="action">{{action}}</v-btn>
<!-- <v-btn flat v-for="action in toolbarActions">{{action}}</v-btn> -->
<!-- <v-btn flat>Link One</v-btn>
<v-btn flat>Link Two</v-btn>
<v-btn flat>Link Three</v-btn> -->
</v-toolbar-items>
</v-toolbar>
</div>
new Vue({
el: '#app',
computed: {
toolbarActions: function() {
return [ 'My project', 'Home', 'About', 'Contact' ]
}
}
})
<script src="https://cdn.jsdelivr.net/npm/vue@2.5.21/dist/vue.js"></script>
<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/vuex/3.0.1/vuex.js"></script>-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/vuetify/1.3.15/vuetify.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/vuetify/1.3.15/vuetify.css" />
<div id="app">
<v-toolbar color="indigo" dark>
<v-toolbar-side-icon></v-toolbar-side-icon>
<v-toolbar-title class="white--text">Title</v-toolbar-title>
<v-spacer></v-spacer>
<v-toolbar-items class="hidden-sm-and-down">
<v-btn flat v-for="action in toolbarActions" :key="action">{{action}}</v-btn>
<!-- <v-btn flat v-for="action in toolbarActions">{{action}}</v-btn> -->
<!-- <v-btn flat>Link One</v-btn>
<v-btn flat>Link Two</v-btn>
<v-btn flat>Link Three</v-btn> -->
</v-toolbar-items>
</v-toolbar>
</div>
edited Dec 30 '18 at 22:15
answered Dec 29 '18 at 23:24
YoarthurYoarthur
679515
679515
1
Bloody hell, this part of code is totally against all rules in documentation. Dont ever do this!data: function() { toolbarActions: this.$store.toolbarActions }
– webmint
Dec 30 '18 at 1:51
I'm running into a number of errors including ' Cannot use 'in' operator to search for 'toolbarActions' in undefined '. Taking a look at nuxtjs.org/guide/vuex-store, I'm assuming that the problem is with the vux store. I tried changing to the edit above.
– user61629
Dec 30 '18 at 2:05
@webmint i fix it by using computed property. This is more suitable for this escenario.
– Yoarthur
Dec 30 '18 at 2:34
1
@Yoarthur Yes, and also what is better to use mapGetters vuex helper.
– webmint
Dec 30 '18 at 14:22
@Yoarthur , please check my edit above
– user61629
Dec 30 '18 at 15:50
|
show 5 more comments
1
Bloody hell, this part of code is totally against all rules in documentation. Dont ever do this!data: function() { toolbarActions: this.$store.toolbarActions }
– webmint
Dec 30 '18 at 1:51
I'm running into a number of errors including ' Cannot use 'in' operator to search for 'toolbarActions' in undefined '. Taking a look at nuxtjs.org/guide/vuex-store, I'm assuming that the problem is with the vux store. I tried changing to the edit above.
– user61629
Dec 30 '18 at 2:05
@webmint i fix it by using computed property. This is more suitable for this escenario.
– Yoarthur
Dec 30 '18 at 2:34
1
@Yoarthur Yes, and also what is better to use mapGetters vuex helper.
– webmint
Dec 30 '18 at 14:22
@Yoarthur , please check my edit above
– user61629
Dec 30 '18 at 15:50
1
1
Bloody hell, this part of code is totally against all rules in documentation. Dont ever do this!
data: function() { toolbarActions: this.$store.toolbarActions }
– webmint
Dec 30 '18 at 1:51
Bloody hell, this part of code is totally against all rules in documentation. Dont ever do this!
data: function() { toolbarActions: this.$store.toolbarActions }
– webmint
Dec 30 '18 at 1:51
I'm running into a number of errors including ' Cannot use 'in' operator to search for 'toolbarActions' in undefined '. Taking a look at nuxtjs.org/guide/vuex-store, I'm assuming that the problem is with the vux store. I tried changing to the edit above.
– user61629
Dec 30 '18 at 2:05
I'm running into a number of errors including ' Cannot use 'in' operator to search for 'toolbarActions' in undefined '. Taking a look at nuxtjs.org/guide/vuex-store, I'm assuming that the problem is with the vux store. I tried changing to the edit above.
– user61629
Dec 30 '18 at 2:05
@webmint i fix it by using computed property. This is more suitable for this escenario.
– Yoarthur
Dec 30 '18 at 2:34
@webmint i fix it by using computed property. This is more suitable for this escenario.
– Yoarthur
Dec 30 '18 at 2:34
1
1
@Yoarthur Yes, and also what is better to use mapGetters vuex helper.
– webmint
Dec 30 '18 at 14:22
@Yoarthur Yes, and also what is better to use mapGetters vuex helper.
– webmint
Dec 30 '18 at 14:22
@Yoarthur , please check my edit above
– user61629
Dec 30 '18 at 15:50
@Yoarthur , please check my edit above
– user61629
Dec 30 '18 at 15:50
|
show 5 more comments
Read about ENV variables.
Also i would suggest u to create js file with values, add there export and use this file variables in nuxt components.
Another variant could be using Vuex store. U can create there for example module mainMeny and define there number of links, titles, and urls.
add a comment |
Read about ENV variables.
Also i would suggest u to create js file with values, add there export and use this file variables in nuxt components.
Another variant could be using Vuex store. U can create there for example module mainMeny and define there number of links, titles, and urls.
add a comment |
Read about ENV variables.
Also i would suggest u to create js file with values, add there export and use this file variables in nuxt components.
Another variant could be using Vuex store. U can create there for example module mainMeny and define there number of links, titles, and urls.
Read about ENV variables.
Also i would suggest u to create js file with values, add there export and use this file variables in nuxt components.
Another variant could be using Vuex store. U can create there for example module mainMeny and define there number of links, titles, and urls.
answered Dec 29 '18 at 21:40
webmintwebmint
1091
1091
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53972567%2fusing-nuxt-site-as-a-template%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown