fix: error alias in typescript example

This commit is contained in:
Clark Du 2017-10-22 12:44:33 +08:00
parent 386096a21e
commit c0a6ed9ea3
3 changed files with 36 additions and 36 deletions

View File

@ -22,5 +22,5 @@ module.exports = {
build: {
vendor: ['axios', 'gsap', 'vuex-class', 'nuxt-class-component']
},
modules: ['~modules/typescript']
modules: ['~/modules/typescript']
}

View File

@ -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>

View File

@ -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);
}
};