事件處理函數(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)然是 []
能取到值但為什么轉(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é)果:
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è)方法就行了。
創(chuàng)建了一個(gè)實(shí)例,用實(shí)例來寫試試:
config.post('/喵', {
onUploadProgress (a){
console.log(a)
},
onDownloadProgress (a){
console.log(a)
}
})
我這邊正常的哇!可以直接用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)
vue是單頁面,路由只是控制元素的顯隱,所以不存在緩存。meta
只是一個(gè)可以讀取的對(duì)象而已,不是設(shè)置http
鏈接的。
路由切換舊的路由組件必定會(huì)destroy。
如果想只執(zhí)行一次這個(gè)鉤子可以判斷這個(gè)頁面時(shí)候進(jìn)來過,如果已經(jīng)訪問過就不執(zhí)行。
http://element-cn.eleme.io/#/... elementUI的樹形控件不知道適不適合你的需求
@
就是在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ù)里的使用。
北大青鳥APTECH成立于1999年。依托北京大學(xué)優(yōu)質(zhì)雄厚的教育資源和背景,秉承“教育改變生活”的發(fā)展理念,致力于培養(yǎng)中國(guó)IT技能型緊缺人才,是大數(shù)據(jù)專業(yè)的國(guó)家
北大青鳥中博軟件學(xué)院創(chuàng)立于2003年,作為華東區(qū)著名互聯(lián)網(wǎng)學(xué)院和江蘇省首批服務(wù)外包人才培訓(xùn)基地,中博成功培育了近30000名軟件工程師走向高薪崗位,合作企業(yè)超4
中公教育集團(tuán)創(chuàng)建于1999年,經(jīng)過二十年潛心發(fā)展,已由一家北大畢業(yè)生自主創(chuàng)業(yè)的信息技術(shù)與教育服務(wù)機(jī)構(gòu),發(fā)展為教育服務(wù)業(yè)的綜合性企業(yè)集團(tuán),成為集合面授教學(xué)培訓(xùn)、網(wǎng)
達(dá)內(nèi)教育集團(tuán)成立于2002年,是一家由留學(xué)海歸創(chuàng)辦的高端職業(yè)教育培訓(xùn)機(jī)構(gòu),是中國(guó)一站式人才培養(yǎng)平臺(tái)、一站式人才輸送平臺(tái)。2014年4月3日在美國(guó)成功上市,融資1
曾工作于聯(lián)想擔(dān)任系統(tǒng)開發(fā)工程師,曾在博彥科技股份有限公司擔(dān)任項(xiàng)目經(jīng)理從事移動(dòng)互聯(lián)網(wǎng)管理及研發(fā)工作,曾創(chuàng)辦藍(lán)懿科技有限責(zé)任公司從事總經(jīng)理職務(wù)負(fù)責(zé)iOS教學(xué)及管理工作。
浪潮集團(tuán)項(xiàng)目經(jīng)理。精通Java與.NET 技術(shù), 熟練的跨平臺(tái)面向?qū)ο箝_發(fā)經(jīng)驗(yàn),技術(shù)功底深厚。 授課風(fēng)格 授課風(fēng)格清新自然、條理清晰、主次分明、重點(diǎn)難點(diǎn)突出、引人入勝。
精通HTML5和CSS3;Javascript及主流js庫,具有快速界面開發(fā)的能力,對(duì)瀏覽器兼容性、前端性能優(yōu)化等有深入理解。精通網(wǎng)頁制作和網(wǎng)頁游戲開發(fā)。
具有10 年的Java 企業(yè)應(yīng)用開發(fā)經(jīng)驗(yàn)。曾經(jīng)歷任德國(guó)Software AG 技術(shù)顧問,美國(guó)Dachieve 系統(tǒng)架構(gòu)師,美國(guó)AngelEngineers Inc. 系統(tǒng)架構(gòu)師。