function test() {
document.getElementById('test').innerHTML--
}
module.exports = test
這樣可以用標(biāo)簽引用啵
<script src="./assets/js/index.js"></script>
報(bào)錯(cuò)module is not defined
以前寫(xiě)的一個(gè)例子
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<title>使用 FileReader 上傳文件</title>
</head>
<body>
<input id="fileInput" type="file" />
<button id="btn" type="button">上傳文件</button>
<script>
const fileInput = document.querySelector('#fileInput');
const btn = document.querySelector('#btn');
fileInput.addEventListener('change', function (e) {
console.log(e);
const file = e.target.files[0];
// 可以獲取上傳的文件詳細(xì)信息
console.log(file);
const formData = new FormData();
formData.append("fileName", "photo.png");
const xhr = new XMLHttpRequest();
// 假設(shè)上傳文件的接口叫 /upload
xhr.open("POST", "/upload");
xhr.send(formData);
});
</script>
</body>
</html>
參考
屬性選擇器。
你只是設(shè)置了起始時(shí)間段,如果想要默認(rèn)顯示的是某一個(gè)時(shí)間,需要調(diào)用picker.setSelectedIndex()方法,對(duì)每一列的數(shù)據(jù)挨個(gè)設(shè)置選中項(xiàng)。
計(jì)算一下你期望顯示的時(shí)間,每一列的索引值,在初始化日期選擇器之后挨個(gè)設(shè)置下。
參考文檔http://dev.dcloud.net.cn/mui/ui/#picker,日期選擇組件是繼承自picker組件的。
如果前后端都是公司自己人做的,那和后端商量下,讓后端做這個(gè)事情比較好。前端的主要功能就是展示,數(shù)據(jù)格式化的工作不應(yīng)該放在前端來(lái)做。后端給出正確的數(shù)據(jù),是基本義務(wù)??赡苡捎诜N種原因,原來(lái)的數(shù)據(jù)格式不適用現(xiàn)在的前端,那就應(yīng)該提出來(lái),不應(yīng)該把不是自己的工作攬?jiān)谏砩?。并不是推卸?zé)任,至少在結(jié)構(gòu)化層面,后端做這個(gè)事讓人看起來(lái)更專業(yè)一些。分工上,前端的能力有限,格式化操作可能需要大量的循環(huán),很容易出現(xiàn)小馬拉大車的現(xiàn)象。如果堅(jiān)持前端來(lái)做這個(gè)事,那就無(wú)所謂優(yōu)雅不優(yōu)雅的問(wèn)題了,這么做已經(jīng)不優(yōu)雅了。
是不是'style-loader' 沒(méi)有安裝好,使用npm install 或者 yarn重新安裝試試。
如果循環(huán)體內(nèi)部用async/await呢?
很顯然你漏了一個(gè)花括號(hào),你的webstorm里面不是給了你提示了么,我標(biāo)注出來(lái)的那一部分就是一個(gè)完整的域,這方面webstorm都做的很好的啊
前端如何通過(guò)后臺(tái)提供的接口文檔將數(shù)據(jù)接好?
1、接口地址、端口問(wèn)清楚
2、是否跨域,跨域如何解決
3、接口異常、報(bào)錯(cuò)、404、500等情況怎么給出相應(yīng)的提示或其他改善用戶體驗(yàn)的措施
react為什么不適合用在web端的項(xiàng)目上?
誰(shuí)說(shuō)的。。。
為什么有的項(xiàng)目有數(shù)據(jù)接口,有的項(xiàng)目數(shù)據(jù)由后臺(tái)寫(xiě)到前端的頁(yè)面?
有的是項(xiàng)目歷史遺留問(wèn)題
有的是因?yàn)閟eo的需求,需要直出頁(yè)面
有的是因?yàn)楫惒秸?qǐng)求對(duì)用戶的體驗(yàn)更友好
用state里面的arr直接存儲(chǔ)expandedrowKeys,
this.state.arr是這樣的:空、不空、空、不空...
使其處于不穩(wěn)定的狀態(tài),應(yīng)該使用穩(wěn)定的數(shù)組存儲(chǔ),然后定期賦值給state里面的expandedrowskeys
this.state.expandedrowsKeys是始終有一項(xiàng)值的
純js實(shí)現(xiàn):
html
<div class="a ">11</div>
<div class="b ">11</div>
<div class="c ">11</div>
css
.b{
background:red;
}
js
function addClass (elements,className){
for (var i=0;i < elements.length;i++){
var element = elements[i];
if(!element.className.match(new RegExp('(\\s|^)'+className+'(\\s|$)'))){
element.className +=' '+className;
}
}
}
var elements = document.getElementsByTagName("div");
addClass(elements,"b");
更新
(setAttr 不覆蓋原來(lái)屬性,如果需要覆蓋修改下代碼即可)
function getAttr(element,attrName){
if(typeof element!='object'||typeof attrName!='string') return;
return attrName =='class'? element.className:element.getAttribute(attrName);
}
function setAttr (element,attrName,attrValue){
if(typeof element !='object'|| typeof attrName!='string' || typeof attrName!='string') return;
var _attrValue = getAttr(element,attrName);
if(!_attrValue){
_attrValue = attrValue;
}else if(!_attrValue.match(new RegExp('(\\s|^)'+attrValue+'(\\s|$)'))){
_attrValue = _attrValue + ' ' + attrValue;
}
attrName == 'class'? element.className=_attrValue:element.setAttribute(attrName,_attrValue);
}
var element = document.getElementsByTagName("div")[0];
setAttr(element,"class","b");
setAttr(element,"id","b");
setAttr(element,"id","b c");
更新
封裝為類似jquery的調(diào)用方式
function MyJquery(selector){ //這里演示,只實(shí)現(xiàn)id選擇器
this.element = document.getElementById(selector);
}
MyJquery.prototype.getAttr = function (attrName){
if(typeof attrName!='string') return;
return attrName =='class'? this.element.className:this.element.getAttribute(attrName);
};
MyJquery.prototype.setAttr = function (attrName,attrValue){
if(typeof attrName!='string' || typeof attrName!='string') return;
var _attrValue = this.getAttr(attrName);
if(!_attrValue){
_attrValue = attrValue;
}else if(!_attrValue.match(new RegExp('(\\s|^)'+attrValue+'(\\s|$)'))){
_attrValue = _attrValue + ' ' + attrValue;
}
attrName == 'class'? this.element.className = _attrValue:this.element.setAttribute(attrName, _attrValue);
};
var $ = function (selector) {
return new MyJquery(selector);
}
$("aa").setAttr("class","b");
用本地服務(wù)器可以打開(kāi)
console.log(1) 輸出了一次還是兩次?
試一下mouseenter事件呢?
擴(kuò)展的話只用修改types就行了
const types = {
'CHARTS':['pie','bar','line'],
'TEXT':['normalText','multText'],
'MEDIA':['file','picture','music','video'],
}
export const typeMarry = (type) => {
for(var k in types)
if(types[k].includes(type))
return k;
}基礎(chǔ)庫(kù)版本應(yīng)該是2.1.0 ,需要綁定小程序與公眾號(hào)
JS:
import lineChart from '../lineChart'
export default {
name: 'demo',
components: {
'line-chart': lineChart
},
// ...
}
HTML:
<template>
<div>
<line-chart></line-chart>
</div>
</template>
css沒(méi)有辦法獲取前一個(gè)元素 不過(guò)可以獲取后面的元素
/*緊鄰*/
i+.ant-upload-list-item-info{}
/*所有*/
i~.ant-upload-list-item-info{} function test() {
function a(){
console.log(" a I'm A ")
return this
}
function b(){
console.log("b I'm B")
return this
}
console.log('test')
return {
a: a,
b: b
}
}
test().a().b()
jquery 是這方面的老大哥,你可以參考下 源碼,不過(guò)這個(gè)夠你 目前 用了
樓下 回答才是正解。。。
北大青鳥(niǎo)APTECH成立于1999年。依托北京大學(xué)優(yōu)質(zhì)雄厚的教育資源和背景,秉承“教育改變生活”的發(fā)展理念,致力于培養(yǎng)中國(guó)IT技能型緊缺人才,是大數(shù)據(jù)專業(yè)的國(guó)家
達(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
北大課工場(chǎng)是北京大學(xué)校辦產(chǎn)業(yè)為響應(yīng)國(guó)家深化產(chǎn)教融合/校企合作的政策,積極推進(jìn)“中國(guó)制造2025”,實(shí)現(xiàn)中華民族偉大復(fù)興的升級(jí)產(chǎn)業(yè)鏈。利用北京大學(xué)優(yōu)質(zhì)教育資源及背
博為峰,中國(guó)職業(yè)人才培訓(xùn)領(lǐng)域的先行者
曾工作于聯(lián)想擔(dān)任系統(tǒng)開(kāi)發(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ū)ο箝_(kāi)發(fā)經(jīng)驗(yàn),技術(shù)功底深厚。 授課風(fēng)格 授課風(fēng)格清新自然、條理清晰、主次分明、重點(diǎn)難點(diǎn)突出、引人入勝。
精通HTML5和CSS3;Javascript及主流js庫(kù),具有快速界面開(kāi)發(fā)的能力,對(duì)瀏覽器兼容性、前端性能優(yōu)化等有深入理解。精通網(wǎng)頁(yè)制作和網(wǎng)頁(yè)游戲開(kāi)發(fā)。
具有10 年的Java 企業(yè)應(yīng)用開(kāi)發(fā)經(jīng)驗(yàn)。曾經(jīng)歷任德國(guó)Software AG 技術(shù)顧問(wèn),美國(guó)Dachieve 系統(tǒng)架構(gòu)師,美國(guó)AngelEngineers Inc. 系統(tǒng)架構(gòu)師。