溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

React及npm的使用常見錯誤;新手來著

發布時間:2020-06-26 11:55:49 來源:網絡 閱讀:1010 作者:12345caixiao 欄目:開發技術
 /*使用npm常見的報錯處理
    (1)更換npm為淘寶的源
    npm install -g cnpm --registry=https://registry.npm.taobao.org
    (2)項目運行的時候;8080端口不要被被占用;因為一個8080端口只能用于一個地方;
    (3)報錯----ERROR in Entry module not found: Error: Cannot resolve 'file' or 'directory' C:\Users\?
    想要作為引用關系的js組件文件不要隨便放到一個dist文件里面;一定要放到component文件夾中;
    (4)在使用Ant Design組件庫的時候
    import { Form, Input, Select, Checkbox, DatePicker, Col, Radio, Button, Modal, message } from 'antd'
    const FormItem = Form.Item
如上面的import里面并不需要加載Form.Item組件;只需要加載Form即可;
     (5)如果要引入包中的某個文件;可以直接使用相對路徑如
    'antd/dist/antd.css'
     (6) 在主文件main.js中
     App組件用來<Route path="/" component={Sider}>書寫路由;
     Sider組件用來寫Link即鏈接單頁面;并且一般如 Link 組件后面不要加 :nbsp;
    (7)import ReactDOM from 'react-dom'
    (8) 動畫的實現
    第1步:現在文件頭部加入這個  var ReactCSSTransitionGroup =require('react-addons-css-transition-group');
    或  var ReactCSSTransitionGrop=React.addons.ReactCSSTransitionGrop;
    第2步: 在要有動畫的元素中加入此標簽<ReactCSSTransitionGroup transitionName="example">
    transitionName代表動畫的名稱;
    第3步:寫css樣式;
    .example-enter         ---》過程先變成這里的樣式
    .example-enter-active  ---》最終變到這里的樣式
    .example-leave         ---》這里的樣式就是example-enter-active類的樣式;所有這里一般不需要加樣式;只要加transition即可;設置移除樣式的時間;
    .example-leave-active  ---》移除元素的過程變成這個樣式

    .example-enter {
    opacity: 0;
    font-size: 32px;
    color:red;
    transition: all 1s ease-in;
    }
    .example-enter.example-enter-active {
    opacity: 1;
    font-size: 12px;
    }

    .example-leave {
    transition: all 1s ease-in;
    color:red;
    }
    .example-leave.example-leave-active {
    font-size: 32px;
    opacity: 0;
    color:red;
    }
    (9)獲取數組;操作數組
    var bvaue="sdf";
    1:往數組中添加元素
    (
    1:var newItems = this.state.items;
    newItems.push(bvaue); this.state.item---->[1,2,3,4];;newItems--->arr對象;
    2:var newItems = this.state.items.push(bvaue);----》這里拿到的是length值;
    )
    2:刪除數組中的元素
    var newItems = this.state.items;
    newItems.splice(i, 1);
    this.setState({items: newItems});
    * */


向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女