• web前端,传统的jquery与vue结合,开发应用


    习惯了vue的写法或者习惯jquery,有时候想大胆的尝试一下二者能不能结合使用,答案是可以的。

    我们这里都使用CDN引用,一起来看下效果吧!

    <!DOCTYPE html>
    <html lang="en">
    
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
        <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
        <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
        <title>Document</title>
        <style>
            ul li {
                list-style: none;
                margin: 10px 0;
                color: darkcyan;
                cursor: pointer;
            }
            .left{
                width: 10%;
                float: left;
            }
            .right{
                width: 89%;
                float: right;
            }
        </style>
    </head>
    
    <body>
        <div id="app">
            <div class="left">
                <ul>
                    <li v-for="item in list" :key="item.index" @click="selectVideo(item.data.content.data.playUrl)">
                        {{item.type}}</li>
                </ul>
            </div>
    
            <div class="right">
                <video :src="videoSrc" controls="controls" width="100%" id="video" ref="video" autoplay>
                </video>
            </div>
            <!-- <button @click="getJqeryMethod">点击</button> -->
        </div>
        <script>
            function initData() {
                console.log("初始化数据");
                 var url="https://api.apiopen.top/videoCategoryDetails?id=14";
                axios.get(url).then(function (data) {
                    console.log(data);
                    app.list = data.data.result;
                })
            }
            $(function () {
                initData();
            })
    
            var app = new Vue({
                el: "#app",
                data: {
                    list: [{ name: "li", url: "http://ivi.bupt.edu.cn/hls/cctv1hd.m3u8" }, { name: "cui", url: "http://ivi.bupt.edu.cn/hls/cctv1hd.m3u8" }],
                    videoSrc: ""
                },
                methods: {
                    getJqeryMethod() {
                        console.log("获取方法");
                        initData();
                    },
                    selectVideo(url) {
                        this.videoSrc = url;
                    }
                },
                mounted() {
                    this.getJqeryMethod()
                },
            })
        </script>
    </body>
    
    </html>

  • 相关阅读:
    springmvc的文件上传和JWT图形验证码
    POJ 2932 Coneology计算最外层圆个数
    POJ1127 Jack Straws
    求逆序对
    P3809 【模板】后缀排序
    匈牙利算法
    POJ2976 Dropping tests
    字符串哈希
    zkw费用流
    最大流Dinic算法
  • 原文地址:https://www.cnblogs.com/agen-su/p/15014266.html
Copyright © 2020-2023  润新知