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