vue操作,顯示數據


vue操作,顯示數據

1.操作頁面上的數據

組件中的內容

<template>
    <div class="about">
        <h1>這是課程頁面</h1>
        <button @click="test">點我</button>
        <p><button @click="data1">得數據</button></p>
        <p>{{course}}</p>
    </div>
</template>

操作組件中的數據

//頁面上的{{course}}數據
//在script中操作
<script>
    export default {
    	//data為操作數據的字段
        data:function(){
            return {
                course:['treadf']
            }
        },
        //methods為操作方法的字段
        methods:{
            test:function () {
                alert('test')
            },
            data1:function () {
                let _this = this
                this.$axios.request({
                    url:'http://127.0.0.1:8001/test/',
                    method:'get'
                }).then(function (response) {
                    _this.course=response.data
                })

            }

        }
    }
</script>


免責聲明!

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



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