Running Vue.js with TypeScript on ASP.NET Core Application
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Hello.vue | |
import axios from 'axios' | |
export default { | |
name: 'hello', | |
data () { | |
return { | |
msg: 'Welcome to Your Vue.js App' | |
} | |
}, | |
created () { | |
axios.get('/api/hello') | |
.then((res) => { | |
this.msg = res.data.message | |
}) | |
.catch((ex) => console.log(ex)) | |
} | |
} | |
// Hello.ts | |
import * as Vue from "vue"; | |
import Component from "vue-class-component"; | |
import axios from "axios"; | |
@Component({ | |
name: "Hello", | |
}) | |
export default class Hello extends Vue { | |
msg: string = "Welcome to Your Vue.js App"; | |
created (): void { | |
axios.get("/api/hello") | |
.then((res) => { | |
this.msg = res.data.message; | |
}) | |
.catch((ex) => console.log(ex)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment