h***@hotmail.com
h***@hotmail.com
  • 发布:2020-11-18 00:31
  • 更新:2020-11-18 11:06
  • 阅读:1119

PC端使用editor报错找不到id

分类:uni-app

问题点:使用了uniapp提供的适配PC的方案,整个屏幕分为左右两块
报错:

代码是editor示例中一模一样未修改的代码。求解
使用uni.createSelectorQuery().in(this).select('#editor1').context()也是不行的

2020-11-18 00:31 负责人:无 分享
已邀请:
incess

incess - 阿莫熊科技,长期合作项目,QQ微信同号 1410323850 专业团队为您解决问题

不是找不到'#editor1'这个id,页面原型链上面的id变量有问题,报错已经写得很清楚了。你要看的 不是uni.createSelectorQuery().in(this).select('#editor1').context(),而是其他的代码

  • h***@hotmail.com (作者)

    我在单一页面是没有报错的,代码放到PC的组合页面就报这个错误了

    2020-11-18 14:02

  • incess

    回复 h***@hotmail.com: 看当前页面代码

    2020-11-18 17:17

  • h***@hotmail.com (作者)

    回复 incess: 当前页面就只有这个编辑器的代码,没有其他代码了

    2020-11-19 00:18

  • incess

    回复 h***@hotmail.com: 你代码都不贴出来

    2020-11-19 09:51

  • h***@hotmail.com (作者)

    <template>

    <view class="container">

    <view class="page-body">

    <view class='wrapper'>

    <editor id="editor" class="ql-container" placeholder="开始输入..." showImgSize showImgToolbar showImgResize

    @statuschange="onStatusChange" :read-only="readOnly" @ready="onEditorReady">

    </editor>

    </view>

    </view>


    </view>  

    </template>


    <script>

    export default {

    data() {

    return {

    readOnly: false,

    formats: {},

    }

    },


        methods: {  
    readOnlyChange() {
    this.readOnly = !this.readOnly
    },
    onEditorReady() {
    console.log(1);
    console.log(uni.createSelectorQuery().in(this).select('#editor').context());
    console.log(2);
    uni.createSelectorQuery().in(this).select('#editor').context((res) => {
    console.log(res);
    console.log(3);
    this.editorCtx = res.context
    }).exec()
    },
    }
    }

    </script>

    2020-11-19 10:45

  • h***@hotmail.com (作者)

    上面是富文本页面的所有代码

    2020-11-19 10:46

  • h***@hotmail.com (作者)

    <template>

    <view>

    <banner class="banner"></banner>

    <view class="body">

    <pages-product-brand-brand v-if="path===2"></pages-product-brand-brand>

    </view>

    <bottom class="bottom"></bottom>

    </view>

    </template>


    <script>

    import banner from '@/components/banner.vue'

    import bottom from '@/components/bottom.vue'

    export default {

    components:{

    banner,

    bottom,

    },

    data() {

    return {

    detail:'',

    path:'',

    };

    },

    created(e) {

    //接受框架中$emit传来的页面

    uni.$on('redlyLeft',(e)=>{

    this.path=e.item.path;

    })

    },


    }  

    </script>

    2020-11-19 10:47

  • h***@hotmail.com (作者)

    这个是PC方案的代码

    2020-11-19 10:47

该问题目前已经被锁定, 无法添加新回复