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