A package for google dfp in framwork vue.
npm install kc-vue-dfpInstalling this package from npm like:
$ npm install kc-vue-dfp@latest --save
Then, just import it like:
import VueDfpProvider from 'kc-vue-dfp/DfpProvider.vue';
And with a few steps like:
1、 have VueDfpProvider be a component:
``javascript`
2、 have to compose an object, its structure looks like:
`javascript`
adunits: {
'section-id': {
'POSITION1': {
'aduid': 'ADUNIT-ID-1'
, 'dimensions': '970x250'
, 'cont-class': [ 'class-1', 'center' ]
},
'POSITION2': {
'aduid': 'ADUNIT-ID-2'
, 'dimensions':'300x250,320x250'
, 'cont-class': [ 'class-1' ]
}
}
}adunits
Put object to data:`javascript`
export default {
...
data() {
return {
dfpid: '40170002',
dfpUnits: adunits,
sectionId: 'section-id'
}
},
...
}
3、 do some markups in template:
`javascript`
//Put all markups in this slot would be the better way to use this pack.
//And, "
Then, the template will be rendered to:
`javascript``
As soon as the DFP code is loaded, the DFP ad will be show correctly.