holder.js 733 字节
Newer Older
fxy060608's avatar
fxy060608 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
export function createHolder (webview, {
  navigationBar
}, {
  Vue
}) {
  const navigationBarState = Vue.observable(navigationBar)

  /* eslint-disable no-new */
  new Vue({
    created () {
      this.$watch(() => navigationBarState.titleText, (val, oldVal) => {
        webview.setStyle({
          titleNView: {
            titleText: val || ''
          }
        })
      })
      this.$watch(() => [navigationBarState.textColor, navigationBarState.backgroundColor], (val) => {
        webview.setStyle({
          titleNView: {
            titleColor: val[0],
            backgroundColor: val[1]
          }
        })
      })
    }
  })

  return {
    navigationBar: navigationBarState
  }
}