您当前的位置: 首页 >  http

彭世瑜

暂无认证

  • 2浏览

    0关注

    2791博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

js:http-vue-loader从浏览器直接引入vue文件

彭世瑜 发布时间:2021-09-17 10:54:56 ,浏览量:2

doc

  • github: https://github.com/FranckFreiburger/http-vue-loader

index.html

doctype html>



  
  



  
    
  

  

    new Vue({
      el: '#app',
      components: {
        'my-component': httpVueLoader('my-component.vue')
      }
    });
  



my-component.vue


  
    Hello {{who}}
  



// 不支持 import
module.exports = {
  data: function () {
    return {
      who: 'world',
    };
  },
  components: {},
};



.hello {
  background-color: #ffe;
}


使用 sass




 

// 可选, 使用scss
httpVueLoader.langProcessor.scss = function (scssText) {
  return new Promise(function (resolve, reject) {
    Sass.compile(scssText, function (result) {
      if (result.status === 0)
        resolve(result.text)
      else
        reject(result)
    });
  });
}

使用 less





httpVueLoader.langProcessor.less = function (lessText) {
  return new Promise(function (resolve, reject) {
    less.render(lessText, {}, function (err, css) {
      if (err) {
        reject(err)
      } else {
        resolve(css.css);
      }
    })
  })
}

参考 Getting started with Sass.js https://github.com/FranckFreiburger/http-vue-loader/issues/20

关注
打赏
1665367115
查看更多评论
立即登录/注册

微信扫码登录

0.1990s