<script type="text/javascript">
window.__STATE__ = <?= json_encode($allData) ?>;
</script>
created () {
if (window.__STATE__ && window.__STATE__.myData) {
this.myData = window.__STATE__.myData;
} else {
axios.get( .... )
}
}
global.ROOT = 'корень проекта';
let config = {
root: {
build: 'dist'
}
};
config.copy = [
{ src: 'source/assets/**', dest: '/'},
{ src: 'source/assets/.htaccess', dest: '/'},
{ src: 'node_modules/tiny-slider/dist/tiny-slider.js', dest: '/design/js' },
{ src: 'node_modules/tiny-slider/dist/tiny-slider.css', dest: '/design/css' },
{ src: 'node_modules/cool-menu/dist/cool-menu.js', dest: '/design/js' },
{ src: 'node_modules/svg4everybody/dist/svg4everybody.js', dest: '/design/js' },
{ src: 'node_modules/vanilla-text-mask/dist/vanillaTextMask.js', dest: '/design/js' },
{ src: 'node_modules/tippy.js/dist/tippy.all.min.js', dest: '/design/js' },
];
function copyFiles(conf, options) {
return new Promise((resolve, reject) => {
if (!('src' in conf)) reject('Invalid config for "copy" task: undefined "src" param');
if (!('dest' in conf)) conf.dest = '';
if ('extensions' in conf) { }
let source = path.join(global.ROOT, conf.src);
let dest = path.join(global.ROOT, options.root.build, conf.dest);
let pipeline = gulp.src(source).pipe(gulp.dest(dest));
pipeline.on('error', function (err) {
reject(err);
});
pipeline.on('end', function () {
resolve();
});
});
}
gulp.task('copy', function(done){
let copies = [];
options.copy.forEach(item => {
copies.push(copyFiles(item, options));
});
Promise.all(copies).then(value => done(), reason => done());
});
function getData() {
//...
return new Promise((resolve, reject) => {
xhr.onreadystatechange = function () {
if (xhr.readyState != 4) reject(xhr.statusText);
if (xhr.status != 200) {
reject(xhr.statusText);
} else {
resolve(xhr.responseText);
}
};
xhr.send();
});
}
// use
getData()
.then(function(response){
console.log('Its OK', response);
})
.catch(function(errorText){
console.log('Error:', errorText);
});
<template>
<b-button
variant="outline-warning"
class="d-block text-white text-uppercase"
:disabled="btnLoading"
>
<span v-text="buttonText"></span>
<i class="fas fa-spinner fa-spin" v-if="btnLoading"></i>
</b-button>
</template>
<script>
...
data() {
return {
tabIndex: 0,
firstServer: {},
product: {},
order: {
nickname: '',
productId: ''
},
btnLoading: false
}
},
computed: {
buttonText() {
return this.btnLoading
? 'Подождите'
: `Купить за ${ this.product.original_price } руб.`;
}
}
...
</script>
Фон менял сам!
/*box-shadow: 0 0 4px 2px #ffffffe6;*/
/*background: #ffffffe6;*/
box-shadow: 0 0 4px 2px rgba(255, 255, 255, 0.9);
background: rgba(255, 255, 255, 0.9);