mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-18 14:41:25 +00:00
fix: error alias in typescript example
This commit is contained in:
parent
386096a21e
commit
c0a6ed9ea3
@ -22,5 +22,5 @@ module.exports = {
|
|||||||
build: {
|
build: {
|
||||||
vendor: ['axios', 'gsap', 'vuex-class', 'nuxt-class-component']
|
vendor: ['axios', 'gsap', 'vuex-class', 'nuxt-class-component']
|
||||||
},
|
},
|
||||||
modules: ['~modules/typescript']
|
modules: ['~/modules/typescript']
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Vue from "vue";
|
import Vue from "vue";
|
||||||
import Component from "nuxt-class-component"
|
import Component from "nuxt-class-component"
|
||||||
import Card from "~components/Card"
|
import Card from "~/components/Card"
|
||||||
import { State, Getter } from "vuex-class"
|
import { State, Getter } from "vuex-class"
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@ -29,4 +29,4 @@ export default class extends Vue {
|
|||||||
@State people
|
@State people
|
||||||
@Getter selectedPerson
|
@Getter selectedPerson
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -1,33 +1,33 @@
|
|||||||
import axios from "~plugins/axios";
|
import axios from "~/plugins/axios";
|
||||||
|
|
||||||
export const state = () => ({
|
export const state = () => ({
|
||||||
selected: 1,
|
selected: 1,
|
||||||
people: []
|
people: []
|
||||||
});
|
});
|
||||||
|
|
||||||
export const mutations = {
|
export const mutations = {
|
||||||
select(state, id) {
|
select(state, id) {
|
||||||
state.selected = id;
|
state.selected = id;
|
||||||
},
|
},
|
||||||
setPeople(state, people) {
|
setPeople(state, people) {
|
||||||
state.people = people;
|
state.people = people;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getters = {
|
export const getters = {
|
||||||
selectedPerson: state => {
|
selectedPerson: state => {
|
||||||
const p = state.people.find(person => person.id === state.selected);
|
const p = state.people.find(person => person.id === state.selected);
|
||||||
return p ? p : { first_name: "Please,", last_name: "select someone" };
|
return p ? p : { first_name: "Please,", last_name: "select someone" };
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const actions = {
|
export const actions = {
|
||||||
async nuxtServerInit({ commit }) {
|
async nuxtServerInit({ commit }) {
|
||||||
const response = await axios.get("/random-data.json");
|
const response = await axios.get("/random-data.json");
|
||||||
const people = response.data.slice(0, 10);
|
const people = response.data.slice(0, 10);
|
||||||
commit("setPeople", people);
|
commit("setPeople", people);
|
||||||
},
|
},
|
||||||
select({ commit }, id) {
|
select({ commit }, id) {
|
||||||
commit("select", id);
|
commit("select", id);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user