A cup of tea, a pack of cigarettes, a bug to change a day...
My life is three times to reflect on my body, why it can be realized, for the gods and horses, it is not realized...
#### Here is a record of strange problems encountered occasionally
1. Routing
2. Style
3. Cross-domain
4. Principle
Confusion problem after vue page style after routing jump
There is a component style that does not add scoped. After loading this component, some styles of the same name or styles defined by tag selectors will become global styles, which will cause other component styles to be overwritten during initial loading. This problem can be solved by adding scoped to the style of the component.
scoped defines the current component style to take effect only in the current page
Dynamically bound image path cannot be rendered
If you encounter this situation, <img :src="item.src">
you can change your mind, change the code to
<img :src="require('../../assets/imgs/'+item.menu_url+'.png')">
// dynamically bind src, use require to introduce variables, and even concatenate strings, nice!
We're sorry but blog doesn't work properly without JavaScript enabled. (解决方案)
The project can't run, you start with the following points
-
The cross-domain configuration in vue.config.js cannot be applied to the production environment.
Solutions :
a.根据不同环境设置不同的baseUrl,生产环境配置不需要跨域的url
b. Can be used as a配置nginx代理
reference -
The route is set to "hash" mode
-
更改publicPath/baseUrl
view
Vue modifies the value of one object and another object changes accordingly
The data defined in data, you assign it to another variable, it is also a shallow copy, the copy is its reference address, it needs to be changed to a deep copy. The
JSON.parse(JSON.stringify())
best solution!