How to add vue to the Baidu Alliance advertisement and vue Alliance

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.