• VUE.js 简单引用


    Vue开发的两种方式:静态资源引入开发 和 脚手架交互式开发

    这里使用的是静态资源引入开发

    首先 引用jquery.js  和  vue.js    

    html 标签内加个

    <div id="box">内容</div>

    <script>
        var vm = new Vue({
            el: '#box',
            data: {
                lists: [],
                adverts: [],
                page: "",
                airdropLists: [],
                airdropId: ''
            },
            created: function () {
                var that = this
                that.token = localStorage.getItem('token')
                console.log(that.token)
                that.post()
                that.getList()
            },
            mounted() { // 通知公告
                var swiper = new Swiper('.swiper-notice', {
                    direction: 'vertical',
                    autoplay: {
                        delay: 3500,
                        disableOnInteraction: false,
                    },
                    observer: true,//修改swiper自己或子元素时,自动初始化swiper
                    observeParents: true//修改swiper的父元素时,自动初始化swiper
                });
            },
            methods: {
                post: function () {
                    var that = this;
                    $.ajax({
                        type: "POST", //提交方式 
                        url: URL + "index.php/Api/Member/advert", //广告
                        dataType: 'json',
                        data: {},
                        success: function (res) { //返回数据根据结果进行相应的处理  
                            console.log(res.data.advert)
                            if (res.code == 1) {
                               that.adverts = res.data.advert
                            }
                        }
                    }) 
                },
                // 获取订单列表
                getList: function () {
                    var that = this
                    $.ajax({
                        type: "POST", //提交方式 
                        url: URL + "/index.php/Api/Airdrop/airdrop_list", //空投列表
                        dataType: 'json',
                        data: {
                            // token: that.token,
                            page: 1
                        },
                        success: function (res) { //返回数据根据结果进行相应的处理 
                            console.log(res)
                            if (res.code == 1) {
                                that.airdropLists = res.data
                            }
                        }
                    })
                },
                login: function (airdrop_id) {
                    var that = this
                    console.log(airdrop_id)
                    that.airdrop_id = airdrop_id
                    console.log(1)
                    if (that.token == null) {
                        window.location.href = "loginRegister.html";
                    }
                    else {
                        window.location.href = "airdropDetails.html?airdrop_id=" + airdrop_id;
                    }
                },
                logined: function () {
                    var that = this
                    if (that.token == null) {
                        window.location.href = "loginRegister.html";
                    }
                },
            },
        });
    
    </script>
  • 相关阅读:
    第三周作业
    第二周作业
    实时控制软件大作业总结
    实时控制软件大作业四
    实时控制软件大作业三
    实时控制软件大作业二
    轨迹插补程序
    实时控制软件大作业博客一
    实时控制软件设计第四周作业
    实时控制软件设计第三周作业-1
  • 原文地址:https://www.cnblogs.com/xiaoxiao2017/p/10675622.html
Copyright © 2020-2023  润新知