How to add vue to the Baidu Alliance advertisement and vue Alliance
After creating the corresponding code bit in the code bit management of the Baidu alliance, click get code to see such a js
Copy and paste the file directly to your webpage to display the corresponding advertisement.
Because all vue components are vue components, you cannot directly add such a piece of js code to the components. We use the following method:
1. First introduce js in the generated code in index.html,
2. In the vue component, write a <div id = "ad_1"> </div>
3. Add the following functions to the mounted hook of the corresponding component:
// Floating style (window. slotbydup = window. slotbydup | []). push ({id: 'u319733 ', container: 'ad _ 1 '});
Id is the cpro_id in the generated code, and container is the id of the created div
At this point, the advertisement can be displayed.
Reference: https://segmentfault.com/q/1010000007738867