鍍金池/ 問答
影魅 回答

事件處理函數(shù)不能設(shè)置為async的,不能會(huì)出問題,你可以把你現(xiàn)在的事件處理函數(shù)里的代碼封裝成一個(gè)函數(shù)。這個(gè)函數(shù)可以加async,然后再調(diào)用

初心 回答

一句話,你的 arr 是有兩個(gè)屬性的空數(shù)組,數(shù)組轉(zhuǎn)字符串當(dāng)然是展示數(shù)組的內(nèi)容,不會(huì)去遍歷數(shù)組的屬性!下面解釋:

js不支持這種關(guān)聯(lián)數(shù)組的形式但為什么可以取值呢?

因?yàn)閿?shù)組本身也是對(duì)象,特殊的對(duì)象,

var arr = new Array();
    arr['school'] = 1;
    arr['team'] = 2;

從對(duì)象的角度來看,你只是給 arr 對(duì)象增加了兩個(gè)屬性,那么你取值,實(shí)際上是讀取屬性,當(dāng)然是可以取到的的;你給 arr 增加值了么?沒有!這個(gè)地方,arr 的 length 還是 0 ,也就是說,arr 還是 [] 空數(shù)組,那么你用 JSON.stringify() 顯示的當(dāng)然是 []

clipboard.png

能取到值但為什么轉(zhuǎn)成json字符串就什么也沒有了呢?

能取到值是因?yàn)槟闳〉氖菍傩?,?shù)組作為對(duì)象,當(dāng)然可以設(shè)置讀取屬性;
轉(zhuǎn)JSON什么都沒有,因?yàn)?arr 是空數(shù)組呀,所以取到的值肯定是 [];


引申,其實(shí)數(shù)組作為特殊的對(duì)象,他的 index,本身也是他的屬性,計(jì)算在length里面,你設(shè)置的 school,team 也是屬性,不算在length里,通常遍歷的時(shí)候,都是按照 index 遍歷的,屬性不遍歷,如果你設(shè)置 index 的屬性,默認(rèn)就是設(shè)置了數(shù)組中的項(xiàng)了,比如你上面的代碼改下,就是不同的結(jié)果:

clipboard.png

我以為 回答

p標(biāo)簽用戶又不能編輯,為什么要確認(rèn)呢?

如果是想讓用戶編輯,可以用 <input type=number>

祉小皓 回答
<script>
  export default {
    data () {
      return {
        show: [],
        items: [
          {id: 1}, {id: 2}, {id: 3}, {id: 4}, {id: 5}
        ]
      }
    },
    mounted () {
      for (let i = 0; i < this.items.length; i++) {
        this.$set(this.show, i, false) // 使用this.$set
      }
    },
    methods: {
      btn (id) {
        this.$set(this.show, id, !this.show[id]) // 使用this.$set
        console.log(this.show)
      }
    }
  }
</script>

在toggle方法后面加this.i = null

如果你還想再次點(diǎn)擊之前點(diǎn)擊的導(dǎo)航,其子級(jí)active不變,就在menus下面為每一個(gè)一級(jí)導(dǎo)航添加activeIndex變量用于記錄子級(jí)導(dǎo)航的激活下標(biāo)。
這樣點(diǎn)擊了權(quán)限管理下的角色管理1,然后點(diǎn)擊電池管理下的用戶管理2,再次回到權(quán)限管理,角色管理1也是激活狀態(tài)

<!DOCTYPE html>  
<html>  
<head>  
    <meta charset="utf-8">  
    <title>vue點(diǎn)擊切換顯示隱藏</title>  
    <script src="https://cdn.bootcss.com/vue/2.2.2/vue.min.js"></script>  
    <style type="text/css">  
    *{  
        padding: 0;  
        margin: 0;  
        font-size: 14px;  
    }  
    ul{  
        width: 200px;  
        height: auto;  
    }  
    h2{  
        background: green;  
        border: 1px solid #fff;  
        color: #fff;  
        height: 30px;  
        line-height: 30px;  
        text-indent: 24px;  
    }  
    h3{  
        background: #999;  
        height: 24px;  
        line-height: 24px;  
        border: 1px solid #fff;  
        text-indent: 50px;  
    }  
    a{
        display: block;
        width: 200px;
    }
    .zhe li.actives{
        color: #fff;
        background: red;
    }
    </style>  
</head>  
<body>  
    <div id="app">
    <ul>
        <li v-for="(menu,menuindex) in menus" style="background:#ccc;margin:10px 0">
            <a  @click="toggle(menu)">{{menu.name}}</a>
            <ul v-show="menu.open" style="background:green;" class="zhe">
                <li v-for="(item,index) in menu.list" @click = "abc(index,menuindex)" :class="{'actives':menu.activeIndex==index}">{{item.name}}</li>
            </ul>
        </li>
    </ul>
</div>
<script>
    new Vue({
        el: "#app",
        data() {
            return {
                     i:null,
                menus: [
                    {
                        name: '權(quán)限管理',
                        open: false,
                        id:'aaa',
                        activeIndex:null,
                        list: [
                            {
                                name: '用戶管理1'
                            },
                            {
                                name: '部門管理1'
                            },
                            {
                                name: '角色管理1'
                            },
                            {
                                name: '菜單管理1'
                            }
                        ]
                    },
                    {
                        name: '電池管理',
                        open: false,
                        id:'bbb',
                        activeIndex:null,
                        list: [
                            {
                                name: '用戶管理2'
                            },
                            {
                                name: '部門管理2'
                            },
                            {
                                name: '角色管理3'
                            },
                            {
                                name: '菜單管理4'
                            }
                        ]
                    }
                ]
            }
        },
        methods:{
            toggle(item) {
                    if(!item.open){
                            this.menus.map((v)=>{
                                v.open=false
                        })
                    }
                    item.open=!item.open
            },
            abc(index,menuindex){
                this.menus[menuindex].activeIndex = index
            }, 
        }
   

    })
</script>
</body>  
</html>  
哎呦喂 回答

如樓上,把index傳入你的點(diǎn)擊事件就可以獲取了

小眼睛 回答
 var icon01 = ImagesConfig.custom ?
            require('../../../../public/imagesConfig/custom/slide1.jpg') :
            require('../../../../public/imagesConfig/default/slide1.jpg') ;

var icon01 = window.ImagesConfig.image01.url;
//**前提是你的ImagesConfig是一個(gè)全局變量,也就是說,你需要在index.html中把你這個(gè)configjs引入(即<script src={你的configjs}></script>),否則你需要將ImagesConfig輸出出去,然后在react中引入(即export&&import這樣)**
        return (

            <div className={'slider'} style={divStyle}>


                <ul className={"slider-main"}>
                    <li className={"slider-panel"}>
                        <img src={icon01} ></img>
                    </li>

                </ul>

            </div>
        )
    }
怪痞 回答

可以使用其他的方法解決。
1、將傳過來的數(shù)據(jù)轉(zhuǎn)化為一個(gè)數(shù)組,然后獲取被選中item的id
2、然后替換成下面的代碼:

<select [(ngModel)]="id" (ngModelChange)="change($event)">
       <option *ngFor="let a of resume.arriveTimeDic" [value]="a.id">
          {{a.name}}
        </option>
 </select>
 

3、重新選擇后 change($event)獲取的是 id,通過這個(gè)id從數(shù)組中獲取value。

陪她鬧 回答

canvas相關(guān)的,酷炫,裝逼,好展示。

柚稚 回答

可以看一下template 模塊嗎 感覺和事件綁定有關(guān)

汐顏 回答

小程序不能直接使用網(wǎng)絡(luò)圖片,也就是說你上面使用的圖片的地址,需要先調(diào)用小程序的wx.downloadFile方法,將返回的本地路徑繪制到canvas。繪制完成后,再調(diào)用保存到相冊(cè)那個(gè)方法就行了。

愛礙唉 回答
  1. 創(chuàng)建了一個(gè)實(shí)例,用實(shí)例來寫試試:

    config.post('/喵', {
        onUploadProgress (a){
            console.log(a)
        },
        onDownloadProgress (a){
            console.log(a)
        }
    })
  2. 或者參考一下這個(gè)例子:axios 實(shí)現(xiàn)上傳圖片進(jìn)度條
莓森 回答

圖片描述

我這邊正常的哇!可以直接用list得到啊

剛試了下,在html里面這么寫也是ok的.
$("#bbb").click(()=>{

let json = [
    [null,"2016-12-31","2016-12-31","2016-12-31","2016-12-31","2016-12-31","2016-12-31"],
    ["","營(yíng)業(yè)收入","營(yíng)業(yè)成本","營(yíng)業(yè)收入","營(yíng)業(yè)成本","營(yíng)業(yè)收入","營(yíng)業(yè)成本"],
    ["華北","10,395.82","4.73","8,041.72","3.65","7,202.08","7,202.08"],
    ["華東","78,942.98","35.93","76,100.98","34.53","70,450.89","70,450.89"],
    ["華南","16,343.33","7.44","21,176.08","9.61","22,709.62","22,709.62"],
    ["華中","41,575.34","18.92","37,104.71","16.84","39,294.05","39,294.05"],
    ["西北","4,581.72","2.09","5,273.01","2.39","4,261.26","4,261.26"],
    ["西南","64,956.49","29.57","69,146.78","31.38","72,990.61","72,990.61"],
    ["境外","1,126.66","0.51","1,278.24","0.58","1,284.34","1,284.34"],
    ["合計(jì)","219,704.55","100.00","220,385.17","100","221,530.55","221,530.55"]
]                  
$.ajax({  
    type : "POST",  
    url : 'http://localhost:10000/app/compose/bbbID',  
    data : JSON.stringify(json),  
    contentType : "application/json",   
    dataType : "json",  
    success:function(msg) {  
        console.log(msg)
    }  
});

})

命多硬 回答

background-size: cover;
或者
object-fit: cover;

涼心人 回答

據(jù)我所知, jetty沒有相關(guān)的實(shí)現(xiàn), 用tomcat7以上的版本吧

假灑脫 回答

你應(yīng)該是想調(diào)用 那些禁用鍵盤事件的方法

var protection = (function () {
    var data = {
        suffix: "com",
        main: "www.",
        red: "bai",
        beauty: "du",
        dot: "."
    }
    var d = (data.main + data.red + data.beauty).toString() + data.dot + data.suffix;
    var url = function () {
        if (document.location.host != "www.baidu.com") {
            location.href = location.href.replace(document.location.host, 'www.baidu.com');
        }
        return location.href;
    }
    var authentication = function () {
        if (window.location.host.indexOf(d) < 0) {
            //$("body").remove();
            document.querySelector('html').removeChild('body');
            return false
        }
        return true
    }

    var shield = function (config) {
        shield.config = config;
        var disable = {
            disableCopy: function (e, keycode) {
                //屏蔽Ctrl+s 保存頁面
                if (e.ctrlKey && keycode == 83) {
                    console.log(shield.config)
                    e.preventDefault();
                    e.returnValue = false;
                }
            },
            disableSource: function (e, keycode) {
                //屏蔽Ctrl+u  查看頁面的源代碼
                if (e.ctrlKey && keycode == 85) {
                    e.preventDefault();
                    e.returnValue = false;
                }
            },
            disableF12: function (e, keycode) {
                //屏蔽F12
                if (keycode == 123) {
                    e.preventDefault();
                    e.returnValue = false;
                }
            },
            disableConsole: function (e, keycode) {
                //屏蔽Ctrl+shift+i   屏蔽調(diào)出控制臺(tái) 和F12一樣
                if (e.ctrlKey && e.shiftKey && keycode == 73) {
                    e.preventDefault();
                    e.returnValue = false;
                }
            }
        }

        document.addEventListener('keydown', function (e) {
            e = window.event || e;
            var keycode = e.keyCode || e.which;
            for (var i = 0; i < shield.config.length; i++) {
                disable[shield.config[i]](e, keycode);
            }
        });
    }
    var facility = {
        geturl: url,
        checkurl: authentication,
        shield: shield
    }
    return facility;
})();

protection.shield(["disableCopy", "disableConsole"]);
//通過js控制
setTimeout(function(){
    protection.shield.config = ["disableCopy"];
},2000)
清夢(mèng) 回答

vue是單頁面,路由只是控制元素的顯隱,所以不存在緩存。
meta只是一個(gè)可以讀取的對(duì)象而已,不是設(shè)置http鏈接的。
路由切換舊的路由組件必定會(huì)destroy。
如果想只執(zhí)行一次這個(gè)鉤子可以判斷這個(gè)頁面時(shí)候進(jìn)來過,如果已經(jīng)訪問過就不執(zhí)行。

不二心 回答

@就是在webpack中設(shè)置的路徑的別名。

你配置之前這么import

import SomeComponent from 'app/assets/javascripts/components/SomeComponent';
import SomeComponent from '../components/SomeComponent';

webpack中設(shè)置別名后:

resolve: {
  alias: {
    "@": "app/assets/javascripts/components",
  },
},

你就可以這樣import了

import SomeComponent from '@/SomeComponent';
孤酒 回答

這取決于你的 changeTest 是同步還是異步,如果這個(gè)方法同步更改,那取到的 test 就是修改后的,因?yàn)樵L問的都是同一個(gè)引用,不存在其他問題。

不過你這里的 test 是 this.props.test,如果是從父組件傳下來的,還涉及到父組件的 render 問題,因?yàn)楦闹岛?,test 是從 props 傳下來的,如果子組件要感知變化,必須是在 render 里才能感知,因?yàn)楦附M件 re-render 才會(huì)給這個(gè)組件重新傳 props。跑偏了,這是渲染的問題。mobx 都是直接引用,只要確保這個(gè),應(yīng)該是會(huì)取到的...

另外,mobx 最重要的還是依賴收集,你這個(gè) case 跟依賴無關(guān),可以多關(guān)心一下 render 函數(shù)里的使用。