首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在vue.js模板中使用注解

如何在vue.js模板中使用注解
EN

Stack Overflow用户
提问于 2021-04-26 16:36:23
回答 2查看 115关注 0票数 1

我想在vue.js (vue 3)模板中使用注解(带有openseadragon插件)。我已经用npm安装了注解。这是我到目前为止所得到的:

代码语言:javascript
复制
    <template>
        <div class="flex-grow">
            <img ref="tag_img" width="100%" :id="img_id" src='../../assets/images/apple.png'>
        </div>
    </template>
    
    <script>
    import * as Annotorious from '@recogito/annotorious-openseadragon'
    import '@recogito/annotorious-openseadragon/dist/annotorious.min.css'
    
    export default {
      props: {
        img_id: String
      },
      mounted: function () {
        var anno = Annotorious({
          image: this.$refs.tag_img
        }, {})
        anno.setDrawingTool('polygon')
      }
    }
    </script>

我在浏览器中收到以下错误:

代码语言:javascript
复制
    [Vue warn]: Error in mounted hook: "TypeError: Cannot read property 'style' of undefined"

found in

---> <AnnotoriousImage> at src/components/interaction/AnnotoriousImage.vue
       <Tagging> at src/components/pages/Tagging.vue
         <App> at src/App.vue
           <Root>
warn @ vue.esm.js?efeb:628
logError @ vue.esm.js?efeb:1893
...
vue.esm.js?efeb:1897 TypeError: Cannot read property 'style' of undefined
EN

回答 2

Stack Overflow用户

发布于 2021-05-01 02:56:09

我相信,你混淆了Annotorious的标准版本(用于图像)和OpenSeadragon插件(用于高分辨率图像,显示在OpenSeadragon查看器中)。

你正在import的是OpenSeadragon版本。但是你初始化的方式和你使用的Annotorious标准版本是一样的。

假设你想注释一个普通的图像: init是正确的。但你需要

代码语言:javascript
复制
 import * as Annotorious from '@recogito/annotorious'
票数 0
EN

Stack Overflow用户

发布于 2021-05-03 20:57:22

Rainer的回答将我带到了一个工作版本。可以将其初始化到注解的mount函数中。

代码语言:javascript
复制
    import OpenSeadragon from 'openseadragon'
    import * as Annotorious from '@recogito/annotorious-openseadragon'
    import '@recogito/annotorious-openseadragon/dist/annotorious.min.css'

export default {
      props: {
        img_url: String,
        default: '../../../assets/images/apple.png'
      },
      mounted: function () {
        const viewer = OpenSeadragon({
          id: 'annotorious_container',
          minZoomImageRatio: 0,
          maxZoomPixelRatio: Infinity,
          tileSources: {
            type: 'image',
            url: require('../../../assets/images/apple.png'),
            ajaxWithCredentials: false,
            fitBounds: true
          }
        })
    
        var options = {
          disableEditor: true // the default editor is disabled to implement a custom behaviour
        }
        var anno = Annotorious(viewer, options)
        anno.setDrawingTool('polygon')
        
        window.viewer = viewer
        window.anno = anno
      },
      components: {
        'Icon': Icon,
        'AnnotoriusEditorPopup': AnnotoriusEditorPopup


         }
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67263348

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档