当前位置: 首页 > news >正文

vue table内修改内容

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
<link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css">
</head>
<body>
    <div id="vue-info">
        <table class="table table-striped table-bordered">
            <thead>
            <tr>
                <th>位置</th>
                <th>图片预览(390*234)</th>
                <th>资讯链接</th>
                <th>标题</th>
                <th>修改时间</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
                <!--<in v-for="top in tops"
                :bind:title="top.title"
                :bind:url="top.url"
                :bind:img="top.img"
                :bind:update="top.update"
                ></in>-->
                <tr is='in' v-for="top in tops" 
                :title="top.title"
                :url="top.url"
                :img="top.img"
                :update="top.update"></tr>
            </tbody>
        </table>
    </div>
    <script src="https://unpkg.com/vue/dist/vue.js"></script>
    <script>
    
    Vue.component('in', {
        template:'\
            <tr>\
                <td>{{id}}</td>\
                <td>\
                    <div v-if="ch">\
                        <img v-bind:src="img" width="100" height="50" />\
                    </div>\
                    <div v-else>\
                        <input type="file" name="img" @change="upload()"/>\
                    </div>\
                </td>\
                <td>\
                    <div v-if="ch">\
                        {{url}}\
                    </div>\
                    <div v-else>\
                        <input type="text" name="url" v-model="url" />\
                    </div>\
                </td>\
                <td>\
                <div v-if="change">\
                        {{title}}\
                    </div>\
                    <div v-else>\
                        <input type="text" name="title" v-model="title" />\
                    </div>\
                </td>\
                <td>{{updated}}</td>\
                <td>\
                    <div v-if="ch">\
                        <button class="btn btn-warning" v-on:click="change()">修改</button>\
                    </div>\
                    <div v-else>\
                        <button class="btn btn-success" v-on:click="sure()">确认</button>\
                        <button class="btn btn-danger" v-on:click="change()">取消</button>\
                    </div>\
                </td>\
            </tr>\
            ',
        props:['url', 'title', 'updated', 'img', 'id'],
        data:function() {
            return {
                ch:true,
                file:0,
            }
        },
        methods: {
            change: function() {
                this.ch = !this.ch;
            },
            upload:function(index) {
                this['file'+index] = event.target.files[0];
            }
        },
    });
    var vm = new Vue({
        el : "#vue-info",
        data: {
            tops: [
                {
                    id:0,
                    img:'',
                    url:'',
                    title:'',
                    status:1,
                    updated:'',
                },
                {
                    id:1,
                    img:'',
                    url:'',
                    title:'',
                    status:1,
                    updated:'',
                }
            ],
        },
        mounted : function() {
        },
        methods: {
        },
    });
        </script>
</body>
</html>

 

转载于:https://www.cnblogs.com/a-flydog/p/6535139.html

相关文章:

  • Uva 11078 简单dp
  • 如何从在线视频网站下载视频
  • mysql考试总结
  • linux 编译内核
  • java nio(一)buffer
  • Sharepoint列表事件处理程序有小问题。
  • git server搭建
  • python、GO中数组的定义。
  • 管理者应有意识地提高以下八项能力
  • *2 echo、printf、mkdir命令的应用
  • 图书 网管天下系列图书 之 网络管理工具实用详解 目录
  • 原生JS与jQuery对AJAX的实现
  • java多线程(一)-概述
  • 网络安全的起跑点Trusted Computing
  • 利用反射——动态调用类中的方法
  • 3.7、@ResponseBody 和 @RestController
  • Android框架之Volley
  • Docker: 容器互访的三种方式
  • Linux各目录及每个目录的详细介绍
  • ng6--错误信息小结(持续更新)
  • python大佬养成计划----difflib模块
  • SpiderData 2019年2月23日 DApp数据排行榜
  • 阿里云爬虫风险管理产品商业化,为云端流量保驾护航
  • 坑!为什么View.startAnimation不起作用?
  • 力扣(LeetCode)21
  • 如何抓住下一波零售风口?看RPA玩转零售自动化
  • 数组的操作
  • 微信开源mars源码分析1—上层samples分析
  • 小程序开发中的那些坑
  • 带你开发类似Pokemon Go的AR游戏
  • 正则表达式-基础知识Review
  • (pt可视化)利用torch的make_grid进行张量可视化
  • (多级缓存)缓存同步
  • (附源码)spring boot智能服药提醒app 毕业设计 102151
  • (四)搭建容器云管理平台笔记—安装ETCD(不使用证书)
  • (转)jdk与jre的区别
  • (转)大道至简,职场上做人做事做管理
  • .NET Project Open Day(2011.11.13)
  • .NET Remoting学习笔记(三)信道
  • .Net Web项目创建比较不错的参考文章
  • .NET 跨平台图形库 SkiaSharp 基础应用
  • .NET 应用启用与禁用自动生成绑定重定向 (bindingRedirect),解决不同版本 dll 的依赖问题
  • .Net的C#语言取月份数值对应的MonthName值
  • .Net高阶异常处理第二篇~~ dump进阶之MiniDumpWriter
  • @DependsOn:解析 Spring 中的依赖关系之艺术
  • [ C++ ] STL_stack(栈)queue(队列)使用及其重要接口模拟实现
  • [APIO2015]巴厘岛的雕塑
  • [AutoSar]BSW_Com02 PDU详解
  • [CentOs7]图形界面
  • [halcon案例2] 足球场的提取和射影变换
  • [Java][Liferay] File system in liferay
  • [JS]Math.random()随机数的二三事
  • [LeetCode]Balanced Binary Tree
  • [Linux] MySQL数据库之索引
  • [Manacher]【学习笔记】