当前位置:网站首页>Shangpinhui knowledge points of large e-commerce projects
Shangpinhui knowledge points of large e-commerce projects
2022-06-30 14:35:00 【tutou_ girl】
Secondary packaging axios
New folder api, Perform secondary encapsulation under this file 、 Unified interface management and other operations .
Unified interface management
Cross-domain problem
What is cross-domain ?
When the browser requests the resources of another domain name from the webpage of one domain name , domain name 、 port 、 The agreement is different , It's all cross domain
To solve the cross domain
1.JSONP
2.CROS
3. agent
Use webpack Agent provided ( In document proxy)
vue.config.js or webpack.config.js Middle configuration
module.exports = {
//...
devServer: {
proxy: {
// Carried by the current platform sending request /api, Request forwarding
'/api': 'http://localhost:9090',
},
},
};
Be careful : There should be before the back-end interface /api Otherwise, report 404
Add to blog If an invalid provider is found on the project, it will still report 404, It turned out blog The project is through webpack The initialization of the ( The launch project is npm run dev),config Under the folder index.js In file proxytable Empty label for , Cross domain configuration is available . Instead of creating vue.config.js File . And the interface is /login instead of /api/login.
VUEX
Data warehouse store, See another blog
VUEX-----store
Function anti shake and throttle
Shake proof : High frequency triggered events , Within the specified unit time , Only respond to the last , If triggered at the specified time , Then recalculate the time ( The events triggered later execute , Replaces the previous event )
// Submit form to add anti shake
SubmitFrom:_.debounce(function(){
this.$refs.ruleForm.validate((valid) => {
if (valid) {
var _this=this
console.log(this.$store.getters.getUser.user_id),
// Request from the back end , Submit data
newBlog(this.editForm,{
"Authorization": localStorage.getItem("token")})
.then(function (response){
if (response.data.data === true)
_this.tips()
_this.$router.push({
path:'/blogs'
})
})
} else {
console.log('error submit!!');
return false;
}
});
console.log('submit!');
},1000),
throttle : High frequency triggered events , Within the specified unit time , Only respond to the first time ( Before the execution of the previous trigger , Ignore subsequent events )
adopt js library lodash Provide encapsulated functions .
_.debounce(func, [wait=0], [options=]) Shake proof
_.throttle(func, [wait=0], [options=]) throttle
Optimize
Event delegation : Delegate the click event of the child element to the parent component .
<el-timeline>
<el-timeline-item :timestamp="blog.created" placement="top" v-for="blog in blogs" :key="blog">
<el-card>
<router-link :to="{name: 'BlogDetail', params: {blogId: blog.id}}">
<h4>{
{
blog.title}}</h4>
</router-link>
<p>{
{
blog.description}}</p>
</el-card>
</el-timeline-item>
</el-timeline>
v-for How many times does the loop have to be created routerlink Component instance of , Memory consumption may cause a stuck phenomenon . If programmed navigation is used , Every a Tags are bound to click event callback , The callback will also be executed repeatedly .
The event delegate is only executed once .
After event delegation :
Now click on the whole piece to jump , How to distinguish between clicked blogs .---------------- Use custom labels ( Must prefix with data-, And the hump will be automatically converted to lowercase , Be careful when deconstructing )
<div class="block" @click="toBlog">
<el-timeline>
<el-timeline-item :timestamp="blog.created" placement="top" v-for="blog in blogs" :key="blog">
<el-card>
<a>
<h4 :data-blogId="blog.id">{
{
blog.title}}</h4>
</a>
<p>{
{
blog.description}}</p>
</el-card>
</el-timeline-item>
</el-timeline>
</div>
toBlog(event){
let element=event.target;
//dataset Get custom tags , Deconstruct the custom tag value
let {
blogid}=element.dataset;
console.log(element.dataset)
this.$router.push({
name:'BlogDetail',
params:{
blogId:blogid
}
})
}
边栏推荐
- When SQL queries are performed in table storage, an error is reported when the primary key is added to the query result, and the query result exceeds 10W rows. Do you want to add multiple indexes to t
- ot initialized – call ‘refresh’ before invoking lifecycle methods via the context: Root WebApplicati
- Problems in QT creator (additional unknown and error lines are listed in the debug output window)
- Error on datetime when importing SQL file from MySQL
- PHP reverses scenarios based on code and skillfully uses debug_ backtrace()
- 1 figure to explain the difference and connection between nodejs and JS
- How to realize selective screen recording for EV screen recording
- After the MySQL service on the local computer is started and stopped, some services will automatically stop when they are not used by other services or programs
- Implementation of forwarding server using IO multiplexing
- ThinkPHP v3.2 comment annotation injection write shell
猜你喜欢

go time. after

Laravel configures passport and returns token using JWT

After the MySQL service on the local computer is started and stopped, some services will automatically stop when they are not used by other services or programs

Shell programming overview

Getting started with shell Basics
![[buuctf] [geek challenge 2019] secret file](/img/00/23bebd013eb4035555c0057725e3c4.jpg)
[buuctf] [geek challenge 2019] secret file

go channel && select

Deep understanding Net (2) kernel mode 4 Summary of kernel pattern constructs

Fastcgi CGI shallow understanding

Mysql database foundation: stored procedures and functions
随机推荐
Je suis à Foshan, où puis - je ouvrir un compte? L'ouverture d'un compte par téléphone mobile est - elle sécurisée?
[scientific research data processing] [practice] frequency analysis chart of category variables, distribution chart of numerical variables and normality test (including lognormal)
Solve the error in my QT_ thread_ global_ End(): 3 threads didn't exit
PHP generate images into Base64
2021 geek challenge Web
Four isolation levels of MySQL
Getting started with shell Basics
[redis series] redis learning 16. Redis Dictionary (map) and its core coding structure
2021-05-12
【BUUCTF】 Have Fun
Thinkphp5 log file contains trick
Race of golang
jsPlumb. Deleteeveryconnection is not a function & jsplumb clear canvas jsplumb delete all nodes and all connections
Laravel configures passport and returns token using JWT
How does hbuilder display in columns?
@Role of ResponseBody
Laravel artist command error
Cost forecast of PMP (BAC, EAC, etc)
DB2 SQL Error: SQLCODE=-206, SQLSTATE=42703
1 figure to explain the difference and connection between nodejs and JS