3分鍾入門Vue.js,讀取MS SQL數據庫並顯示html內容


今 天又學習一門前端,叫Vue.js。

在VS中,使用NuGet下載Vue.js和axios.js:

 

 

引用至html網頁中:

 

在script里,寫幾行讀數據接口的代碼:

 

new Vue({
        el: '#app',
        data() {
            return {
                info: null
            }
        },
        mounted() {
            axios
                .post('/api/Content/GetAboutContent', 
                    {
                        Parmkey: 0
                })
                .then(response => (this.info = response.data.Content))
                .catch(function (error) { 
                    console.log(error);
                });
        }
    })
Source Code

 

以上,一處為接口路徑,一處為POST傳入參數。

 

在網頁呈現html內容:

 

下面是顯示效果與數據庫存儲的html內容:

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM