-
-
Save justinyoo/bb36d6dc010b57bfd91c34d2cecf3ce7 to your computer and use it in GitHub Desktop.
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 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