最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

vue實(shí)現(xiàn)記事本小功能

 更新時(shí)間:2021年11月22日 17:26:00   作者:小仙女ya  
這篇文章主要為大家詳細(xì)介紹了vue實(shí)現(xiàn)記事本小功能,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了vue實(shí)現(xiàn)記事本小功能的具體代碼,供大家參考,具體內(nèi)容如下

直接上代碼:

<!DOCTYPE html>
<html lang="en">
<script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<head>
    <style>
        #app {
            margin: 0px auto;
            width: 500px;
            border: 1px solid gainsboro;
            height: auto;
        }
        .title {
            line-height: 50px;
            text-align: center;
            height: 50px;
            font-weight: 20;
            font-size: 36px;
            background: #42b983;
            border-bottom: 1px solid black;
        }
        input:focus {
            border-color: #66afe9;
            outline: 0;
            -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 8px rgba(102, 175, 233, .6);
            box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 8px rgba(102, 175, 233, .6)
        }
        .file-container{
            overflow: hidden;
            margin-top: 10px;
        }
        .openfile-btn{
            float: left;
            margin-left: 10px;
        }
        #file_path{
            margin-left: 10px;
            width: 300px;
        }
        #file_con{
            display: block;
            border:0;
            border-radius:5px;
            background-color:rgba(241,241,241,.98);
            width: 480px;
            height: 250px;
            margin-top: 10px;
            margin-left: 10px;
            resize: none;
        }
        ul,
        li {
            padding: 0;
            margin: 0;
            list-style: none;
        }

        .li-div {
            text-align: center;
            overflow: hidden;
            margin-top: 5px;
            /*border: 3px solid blanchedalmond;*/
        }
        .bot{
            height: 30px;
        }
        .show-details{
            float: right;
            margin-right: 10px;
        }
        .show-btn{
            /*display: block;*/
            float: right;
            margin-right: 10px;
        }
    </style>
</head>

<body>
<div id="app">
    <div class="title">
        記事本
    </div>
    <div>
        <div class="file-container">
            <input class="openfile-btn" type="button" value="從本地導(dǎo)入" id="fileImport" v-on:click="clickLoad">
            <input type="file" id="files" ref="refFile" style="display: none" v-on:change="fileLoad">
            <input type="text" v-model="path" id="file_path" disabled="disabled">
            <input type="button" value="確定導(dǎo)入" style="float:right; margin-right: 10px " v-on:click="addfile"></button>
            <textarea type="text" id="file_con" autoHeight="true" v-model="input_file"></textarea>
        </div>

    </div>
    <hr>
    <div class="content">
        <ul>
            <li v-for="(item, index) in message">
                <div class="li-div">
                    <span>{{++index}}</span>
                    <label>{{item}}</label>
                    <button @click="remove(index)" class="show-btn">刪除</button>
                    <button @click="show(index)" class="show-btn" v-if="item.length>30">詳情</button>
                </div>
            </li>
        </ul>
    </div>
    <hr>
    <div v-show="message.length>0" class="bot">
        <div style="float: left; margin-left: 10px">
            當(dāng)前記事本記錄數(shù):{{message.length}}
        </div>
        <div class="del-btn">
            <button @click="clear"class="show-btn">清空</button>
        </div>
    </div>
</div>
<script>
    let app = new Vue({
        el: '#app',
        data: {
            //tmp: "",
            message: [],
            path:'',
            input_file:'',
            sub_inpufile:'',
            tmp_file:''
        },
        methods: {
            clickLoad: function (){
                this.$refs.refFile.dispatchEvent(new MouseEvent('click'))
            },
            fileLoad() {
                const selectedFile = this.$refs.refFile.files[0];
                var name = selectedFile.name; //選中文件的文件名
                var size = selectedFile.size; //選中文件的大小
                var reader = new FileReader();
                reader.readAsText(selectedFile);
                this.path = name;
                console.log("文件名:" + name + "大小:" + size);

                reader.onload = function() {
                    let file_s = this.result;
                    document.getElementById('file_con').value=file_s;
                }
            },
            addfile:function (){
                var file = document.getElementById('file_con').value;
                this.input_file=file;
                this.tmp_file=file;  //用來存儲(chǔ)原文件
                //console.log("this.input_file:"+this.input_file)
                if (file == null || file == "") {
                    alert("輸入不能為空");
                } else {
                    if(file.length>30)
                    {
                        this.sub_inpufile=file.substring(0,30)+'...'
                        this.message.push(this.sub_inpufile);
                        this.input_file=''
                        this.path=''
                        console.log(this.sub_inpufile)
                    }
                    else{
                        this.message.push(this.input_file);
                        this.input_file=''
                        this.path=''
                    }
                }
            },
            remove: function (index) {
                var flag = confirm("是否要?jiǎng)h除刪除" + index);
                if (flag == true) {
                    this.message.splice(index-1, 1);
                }
            },
            show:function (){
                alert(this.tmp_file)  //有字?jǐn)?shù)限制,可自定義組件
            },
            clear: function () {
                this.message = [];
            },
        },
    })
</script>
</body>
</html>

效果:

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • vue項(xiàng)目中Token的使用方式

    vue項(xiàng)目中Token的使用方式

    這篇文章主要介紹了vue項(xiàng)目中Token的使用方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2024-09-09
  • vue3?element?plus按需引入最優(yōu)雅的用法實(shí)例

    vue3?element?plus按需引入最優(yōu)雅的用法實(shí)例

    這篇文章主要給大家介紹了關(guān)于vue3?element?plus按需引入最優(yōu)雅的用法,以及關(guān)于Element-plus按需引入的一些坑,文中通過圖文介紹的非常詳細(xì),需要的朋友可以參考下
    2022-03-03
  • 從零擼一個(gè)pc端vue的ui組件庫(kù)( 計(jì)數(shù)器組件 )

    從零擼一個(gè)pc端vue的ui組件庫(kù)( 計(jì)數(shù)器組件 )

    這篇文章主要介紹了pc端vue的ui組件庫(kù)的實(shí)現(xiàn)方法,非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2019-08-08
  • vue.js指令和組件詳細(xì)介紹及實(shí)例

    vue.js指令和組件詳細(xì)介紹及實(shí)例

    這篇文章主要介紹了vue.js功能介紹 - 指令,組件詳細(xì)介紹及實(shí)例,詳細(xì)的介紹了指令和組件的用法,有興趣的可以了解一下。
    2017-04-04
  • 使用Vue開發(fā)動(dòng)態(tài)刷新Echarts組件的教程詳解

    使用Vue開發(fā)動(dòng)態(tài)刷新Echarts組件的教程詳解

    這篇文章主要介紹了使用Vue開發(fā)動(dòng)態(tài)刷新Echarts組件的教程詳解,需要的朋友可以參考下
    2018-03-03
  • 深入理解vue3中的reactive()

    深入理解vue3中的reactive()

    本文主要介紹了深入理解vue3中的reactive(),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2023-02-02
  • Vue3使用Suspense優(yōu)雅地處理異步組件加載的示例代碼

    Vue3使用Suspense優(yōu)雅地處理異步組件加載的示例代碼

    Vue3是Vue.js的最新版本,它帶來了許多令人興奮的新特性和改進(jìn),其中一個(gè)重要的特性是Suspense,它為我們提供了一種優(yōu)雅地處理異步組件加載和錯(cuò)誤處理的方式,本文給大家介紹了Vue3使用Suspense優(yōu)雅地處理異步組件加載的示例,需要的朋友可以參考下
    2024-01-01
  • 淺談Vue CLI 3結(jié)合Lerna進(jìn)行UI框架設(shè)計(jì)

    淺談Vue CLI 3結(jié)合Lerna進(jìn)行UI框架設(shè)計(jì)

    這篇文章主要介紹了淺談Vue CLI 3結(jié)合Lerna進(jìn)行UI框架設(shè)計(jì),在此之前先簡(jiǎn)單介紹一下Element的構(gòu)建流程,以便對(duì)比新的UI框架設(shè)計(jì)。小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2019-04-04
  • Vue2.0 vue-source jsonp 跨域請(qǐng)求

    Vue2.0 vue-source jsonp 跨域請(qǐng)求

    這篇文章主要介紹了Vue2.0 vue-source jsonp 跨域請(qǐng)求,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2017-08-08
  • Ant?Design?of?Vue?select框獲取key和name的問題

    Ant?Design?of?Vue?select框獲取key和name的問題

    這篇文章主要介紹了Ant?Design?of?Vue?select框獲取key和name的問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-06-06

最新評(píng)論

阳西县| 随州市| 嘉善县| 屯门区| 南通市| 石狮市| 株洲县| 汝南县| 凤山县| 仁怀市| 神农架林区| 平和县| 桦川县| 西贡区| 柳江县| 宝丰县| 漠河县| 顺义区| 衡山县| 海城市| 汶川县| 白城市| 黔西县| 翁牛特旗| 南木林县| 厦门市| 息烽县| 新民市| 惠东县| 腾冲县| 滦南县| 山东省| 西乡县| 容城县| 长宁区| 长汀县| 威远县| 德江县| 江达县| 北京市| 镇沅|