鍍金池/ 問答/ HTML問答
入她眼 回答

每一個mt-tab-item有1個id,mt-tabbarv-model綁定值等于id時即選中。設置你的selected默認值為第一個mt-tab-itemid

墻頭草 回答

fn.apply(this, [self]) 這里你傳入的參數就只有一個,當然在 fn 內取不到 b 和 c 了。

調用 fn 的時候至少應該再傳兩個參數進去?。?code>fn.apply(this, [self, b, c])。不過這里的 b 和 c 是什么我就不知道了,要看你的業(yè)務邏輯

膽怯 回答

我覺得,你花這點時間提問,都可以寫一個demo了,何不自己寫一個看看呢?

墻頭草 回答

No 'Access-Control-Allow-Origin' header is present on the requested resource.

跨域請求錯誤,要后端將響應頭Access-Control-Allow-Origin設置成*就好了

浪蕩不羈 回答

不知道canvas和flex布局有什么關系......

萌小萌 回答

使用異步組件即可,參見 Vue 官方文檔

踩這個答案的,你的良心不會痛嗎?這個答案告訴你需要了解的概念,以及從哪里可以獲取最正確最權威的指導。

clipboard.png
可以指出哪里需要改進,如何改進,而不是只是這么暗戳戳地踩一下嗎?

學習是你自己的事,少年

舊酒館 回答

babel只是按照你配置的環(huán)境進行轉碼了啊,所謂的轉碼其實也就是把一些瀏覽器不支持的新語法,轉換成老語法.

你的問題是問你要如何做到兼容所有版本瀏覽器嗎? 還是不知道babel如何按照瀏覽器轉碼?

  1. 兼容所有瀏覽器只需要兼容低版本就可以了,因為js大部分特性是可以做到向下兼容的.也就是新瀏覽器仍然支持老語法.

  2. babel按照你輸入的瀏覽器版本和其他條件,去查詢對應的js支持版本,然后找到所有條件下支持的最高級別Js版本,轉碼到該版本.轉碼過程跟瀏覽器沒有任何關系,只是在node環(huán)境中進行.

硬扛 回答

其實你身份證號只驗證位數也不是很嚴謹,港澳臺回鄉(xiāng)證是什么樣格式的?

墨小白 回答

swiper在后臺數據沒有回來已經初始化了,swiper-slide 循環(huán) data ,加上這個 v-if=“data.length”,獲取數據了之后再渲染

情未了 回答

你在里面的時候吧函數定義到全局就可以了
這樣

window.downloadPictureForIOS = downloadPictureForIOS;

外面就可以調用了 不過你全局調用的話 能保證相關的庫已經加載完了嗎

憶往昔 回答
  1. 按需引入 iview https://www.iviewui.com/docs/...

  2. 按需引入 echarts https://github.com/ywwhack/ba...

最后建議,把這些需要按需加載的模塊放到統(tǒng)一放到一個文件里,后面好維護

別瞎鬧 回答

已自行解決。

吃藕丑 回答

頂一波樓上,將日期寫到變量中,再在插件中綁定默認值這個屬性

命于你 回答

目錄結構

|-src
|----actions
|--------user.js
|--------office.js
|--------index.js
|----reducers
|--------user.js
|--------office.js
|--------index.js
|----pages
|--------office.js

Action整合

actions目錄中的index.js作為所有業(yè)務的集合,集中配置管理.

actions/index.js

import * as officeActions from './office';
import * as userActions from './user';

export default {
    ...officeActions,
    ...userActions,
}

actions/office.js

//這里的方法名稱要全局唯一
export function getOfficeList(){
    return async(dispatch,getState) => {
        let response = await fetch(url);
        //這里的type一定要全局唯一,因為狀態(tài)變一次每個Reducer都會根據類型比對一遍
        dispatch({type: 'GET_OFFICE_LIST', payLoad: response.json});
    }
}
export function getOfficeInfo(id){
    return async(dispatch,getState) => {
        let response = await fetch(url+'?id='+id);
        //這里的type一定要全局唯一,因為狀態(tài)變一次每個Reducer都會根據類型比對一遍
        dispatch({type: 'GET_OFFICE_DETAIL', payLoad: response.json});
    }
}

actions/user.js

//這里的方法名稱要全局唯一
export function getUserList(){
    return async(dispatch,getState) => {
        let response = await fetch(url);
        //這里的type一定要全局唯一,因為狀態(tài)變一次每個Reducer都會根據類型比對一遍
        dispatch({type: 'GET_USER_LIST', payLoad: response.json});
    }
}

Reducer整合

Reducer目錄中的index.js 所有子狀態(tài)的集合,集中配置管理.

reducers/index.js

import {combineReducers} from 'redux';

import officeReducer from './office';
import userReducer from './user';

const appReducer = combineReducers({
    office: officeReducer,
    user: userReducer,
});
export default appReducer;

reducers/office.js

//初始化狀態(tài)
let initialState = {
    officeList: [],
    officeInfo: {
        "id": "",
        "parent_id": "",
        "parent_ids": "",
        "name": "",
    },
};
const office = (state = initialState, action) => {
    switch (action.type) {
        //處理 類型為 GET_OFFICE_LIST 結果數據
        case 'GET_OFFICE_LIST':
            return Object.assign({}, state, {
                officeList: action.payLoad.data
            });
        //處理 類型為 GET_OFFICE_DETAIL 結果數據
        case 'GET_OFFICE_DETAIL':
            return Object.assign({}, state, {
                officeInfo: action.payLoad.data
            });
        default:
        //如果類型為匹配到 返回當前state
            return state;
    }
};
export default office

最終使用

pages/office.js

import React, {Component} from 'react'
import {bindActionCreators} from 'redux';
import {connect} from 'react-redux';

//以antd為例
import {Table, Tree, Row, Col, Card, Button, Spin, Modal,Icon} from 'antd';
//引入Action集合,因為很有可能某個頁面 需要調用多個子action
import Actions from '../actions';

class office extends Component {
    //生命周期此次不討論
    componentDidMount() {
        //請求機構 數據
        this.props.action.getOfficeList();
  }

    handleOnRowClick = (officeId)=>{
        //點擊行 獲取結構詳情數據
        this.props.action.getOfficeInfo(officeId);
    }
    
    render() {
        <div className="tableDistance">
        <Table rowSelection={rowSelection} columns={columns}
               dataSource={this.props.office.officeList}//綁定機構數據并展現
               bordered size="middle"
               pagination={false} onRowClick={this.handleOnRowClick}
        />
    </div>
    }

}
//我習慣叫訂閱-訂閱Reducer/index.js集合中的需要的狀態(tài),reducer/office在這里進行綁定(數據結構具體見:initState),reducer/office數據變化這里就會變化,這里可以理解為數據源
const mapStateToProps = (state) => {
    return {
        office: state.office,
        user:state.user
    }
};
//將引入的Actions綁定,使當前展現層具備 請求數據的能力,需要什么數據,就請求對應的 方法名(這就是為什么腔調actions/office.js 中的每個action 名稱一定要全局唯一,還是那句話,這個頁面可能需要多個子action的數據能力作為數據集中展現的基礎)
const mapDispatchToProps = (dispatch) => {
    return {
        action: bindActionCreators(Actions, dispatch)
    }
};
//最重要一步 通過react-redux 提供的 connect函數將 需要的 Reducer和Actions 綁定至 當前頁面
export default connect(mapStateToProps, mapDispatchToProps)(office);

夢一場 回答

加分號啊。老生常談了。

function test(){
    
}
test.prototype = function(){
    console.log("test_prototype");
}; //這里加分號,否則就連成一條語句執(zhí)行了
(function(){
    console.log("立即執(zhí)行函數");
})()

// 不加分號,瀏覽器就是這樣認為的:

test.prototype = (function(){
    console.log("test_prototype");
})(function(){
    console.log("立即執(zhí)行函數");
})()

// 也就是這樣的:
f1 = function(){
    console.log("test_prototype");
};
f2 = function(){
    console.log("立即執(zhí)行函數");
};
test.prototype = f1(f2)()
尕筱澄 回答

不用箭頭函數就行了唄 要不就new Array(10).fill(0).map(_ => console.log(this).bind([])

有點壞 回答

1.4.0 小程序開始有 WXML節(jié)點信息的API

可以通過這個來進行操作。

里面有一個boundingClientRect 不正是可以利用的API?

https://mp.weixin.qq.com/debu...

挽歌 回答

webpack等工具,能自動解析模塊的加載,你使用了react那么你不可能不用這個吧?。?!

病癮 回答

在main.js里直接import '../xx.less'
所有的全局樣式都可以在這引入。