前端小白求问,写法1中导出函数没用到const修饰,相比较第二种写法会不会用性能上的弊端。
写法1:
import Http from './http'
import GLOBAL from '../global_variable'
const ADD_CAR = `${GLOBAL.PMS_REQUEST_ROOT}/base/addCar`
const DELETE_CAR = `${GLOBAL.PMS_REQUEST_ROOT}/base/deleteCar`
const UPDATE_CAR = `${GLOBAL.PMS_REQUEST_ROOT}/base/updateCar`
const QUERY_CAR = `${GLOBAL.PMS_REQUEST_ROOT}/base/queryCar`
export default{
addCar:function(opt){
return Http(ADD_CAR, opt)
},
deleteCar:function(opt){
return Http(DELETE_CAR, opt)
},
updateCar:function(opt){
return Http(UPDATE_CAR, opt)
},
queryCar:function(opt){
return Http(QUERY_CAR, opt)
},
}
写法2:
import Http from './http'
import * as API from './api'
export const getRole = function (opt) {
return Http(API.getRole, opt)
}
export const addRole = function (opt) {
return Http(API.addRole, opt)
}
export const delRole = function (opt) {
return Http(API.delRole, opt)
}
跟性能不搭边,引用方式第一个要简单一些,因为第一种你导出了一个对象,直接用差值表达式就可以引用
meiyou
这个和性能应该是没关系的