poster.js 593 B

1234567891011121314151617181920212223242526272829
  1. const defaultOptions = {
  2. selector: '#poster'
  3. };
  4. function Poster(options = {}, that) {
  5. options = {
  6. ...defaultOptions,
  7. ...options,
  8. };
  9. const pages = getCurrentPages();
  10. let ctx = pages[pages.length - 1];
  11. if (that) ctx = that
  12. const poster = ctx.selectComponent(options.selector);
  13. delete options.selector;
  14. return poster;
  15. };
  16. Poster.create = (reset = false, that) => {
  17. const poster = Poster({}, that);
  18. if (!poster) {
  19. console.error('请设置组件的id="poster"!!!');
  20. } else {
  21. return Poster({}, that).onCreate(reset);
  22. }
  23. }
  24. export default Poster;