小编jj0*_*008的帖子

羽毛笔编辑器 - 焦点

每当我创建编辑器的另一个实例时(在我的例子中,通过 onkeypress 事件),当我创建新编辑器时,我会失去对正在输入的编辑器的关注。如何防止所有编辑对任何事件失去注意力?

html quill

7
推荐指数
2
解决办法
4096
查看次数

ActionView::Template::Error at / 未初始化的常量

当我尝试加载我的应用程序时出现以下错误:

ActionView::Template::Error at /
uninitialized constant ActionView::CompiledTemplates::EXPR_ARG
Run Code Online (Sandbox Code Playgroud)

发现错误app/views/layouts/application.html.haml并突出显示以下代码。

!!! 5
%html{:lang => "en"}
  %head
    = render partial: 'common/html_head'
  %body#static{ class: body_css_class }
    = content_for?(:base_content) ? yield(:base_content) : yield
Run Code Online (Sandbox Code Playgroud)

有没有人知道这是什么?

ruby activerecord ruby-on-rails rails-activerecord

5
推荐指数
1
解决办法
810
查看次数

git merge(自动合并)时出现重复代码

我注意到,当我使用 合并时git pull,有时我的代码可能会出现不良结果。例如,

在远程分支上:

function(){
  functionOne();
  functionTwo();
  functionThree();
}
Run Code Online (Sandbox Code Playgroud)

在本地分支机构:

function(){

  functionThree();
  functionTwo();
}
Run Code Online (Sandbox Code Playgroud)

合并后:

function(){
  functionThree();
  functionTwo();
  functionThree();
}
Run Code Online (Sandbox Code Playgroud)

上面是一个简化的例子,试图说明我的经历。当我编码时,我倾向于用空行移动代码,并且我不经常与远程分支(主)合并,我不确定这在合并时是否有任何影响。我怎样才能避免这种情况?

git

5
推荐指数
0
解决办法
800
查看次数

移除/关闭 Firebase 侦听器

我有监听 Firebase 事件的 Vue 组件,并且在安装它们时创建 Firebase 参考/侦听器。但是当用户离开该页面时,我想删除beforeDestroy()生命周期挂钩中的所有侦听器。这是删除 Firebase 引用/侦听器的“正确”方法吗?

getFirebaseRef(path){
  return firebase.database().ref(path)
},

beforeDestroy(){
  // get firebase ref
  let fbPath = `/projects/proj_${this.currentLessonId}/components/${this.component.id}`
  this.getFirebaseRef(fbPath)
  .then((ref) => {
    // remove listener
    ref.off("value", (snap) => {
    })
    ref.off("child_added", (snap) => {
    })
    ref.off("child_removed", (snap) => {
    })
  })
},


mounted(){
  // get firebase ref
  let fbPath = `/projects/proj_${this.currentLessonId}/components/${this.component.id}`
  this.getFirebaseRef(fbPath)
  .then((ref) => {
    // add listener
    ref.on("value", (snap) => {
      doSomething1()
    })
    ref.on("child_added", (snap) => {
      doSomething2()
    })
    ref.on("child_removed", (snap) => { …
Run Code Online (Sandbox Code Playgroud)

javascript firebase vue.js firebase-realtime-database

4
推荐指数
1
解决办法
8702
查看次数

从 Github API 解码内容

我正在尝试向 Github api 发出请求,并从打开的存储库中的文件中获取内容(代码)。我curl -i在终端上做了一个简单的操作,它返回了一些已编码的内容(根据文档)。如何解码该内容?当我将代码输出到 html textarea 时,是否可以将代码置于正确的格式(缩进等)中?

github-api

3
推荐指数
1
解决办法
2684
查看次数

Vue子组件等待道具

我有一个将组件(property)(selectedOption)传递给子组件的父组件,该子组件采用该道具并基于该道具渲染图标。但是每次加载页面时,子组件都会引发错误,因为prop没有及时传递,但是在传递所有内容后的一秒钟就可以了。如何避免这种情况?

父级(Settings.vue):

<template>
    <settings-menu
      :selectedOption="selectedSettingsOption">
    </settings-menu>
Run Code Online (Sandbox Code Playgroud)

子(SettingsMenu.vue):

<template>
  <component
    :is="`icon-${ selectedOption }`">
  </component>
</template>
Run Code Online (Sandbox Code Playgroud)

vue.js vue-component

3
推荐指数
1
解决办法
2794
查看次数

Vue 本地数据使用 Getter

我正在尝试根据商店(课程)中的内容设置数据属性(在课堂中)。但我不断得到undefined。如何获取该值并将其设置在数据中?

Classroom.vue:

data(){
  return {
    selectedOption: this.currentLesson
  }
}

computed: Object.assign({},
  mapGetters({
    currentLesson: "lesson/current"
  })
)
Run Code Online (Sandbox Code Playgroud)

课程.js:

const state = {
  current: {}
}

const getters = {
  current(){
    return state.current
  },
}
Run Code Online (Sandbox Code Playgroud)

索引.js:

export default new Vuex.Store({
  modules: {
    lesson,
    user
  }
})
Run Code Online (Sandbox Code Playgroud)

javascript vue.js

3
推荐指数
1
解决办法
2229
查看次数

查找并替换数组中的对象(基于id)

这里有一点难题...我想循环allItems并返回allItems但替换任何newItems匹配其ID.如何查找匹配项id,然后将其替换为正确的对象到数组中?

const allItems = [
  {
    'id': 1,
    'category_id': 1,
    'text': 'old',
  },
  {
    'id': 2,
    'category_id': 1,
    'text': 'old'
  }
]

const newItems = [
  {
    'id': 1,
    'category_id': 1,
    'text': 'new',
    'more_info': 'abcd'
  },
  {
    'id': 2,
    'category_id': 1,
    'text': 'new',
    'more_info': 'abcd'
  }
]
Run Code Online (Sandbox Code Playgroud)

到目前为止我尝试了什么:

for(let i = 0; i < allItems.length; i++) {
  if(newItems.indexOf(allItems[i].id) > -1){
    allItems[i] = newItems
  }
}
Run Code Online (Sandbox Code Playgroud)

如何获取对象的位置newItems然后将其替换为allItems

javascript arrays object ecmascript-6

3
推荐指数
1
解决办法
809
查看次数

不支持的操作方法签名。必须返回 MPRemoteCommandHandlerStatus

每当我在 iOS 13+ 上运行模拟器时都会收到此错误。一切都适用于 iOS 12 及更低版本,所以我不确定在这里做什么。有什么我可以改变/编辑的东西来react-native-music-control为 iOS 13 工作吗?

Exception 'Unsupported action method signature. Must return MPRemoteCommandHandlerStatus or take a completion handler as the second argument.' was thrown while invoking enableControl on target MusicControlManager with params ( pause, 1, { } )

react-native

3
推荐指数
1
解决办法
1833
查看次数

vue 组件上的内联 css

我正在尝试在 vue 中的 div 上应用背景颜色,并且我能够从我的数据中传入一个 hex_code,但我想对rgba背景应用样式。我的语法有问题吗?

      <div
        v-for="item in itemList"
        :style="{ 'background-color': `rgba(${ item.hex_code }, 0.5)` }"
        :key="item.id">
     </div>
Run Code Online (Sandbox Code Playgroud)

css vue.js

1
推荐指数
1
解决办法
1055
查看次数

Vue Draggable - 拖放后动态更改组件

我有两个独立的拖动区域,当我将组件从一个区域拖动到另一个区域时,如何根据组件被拖动到的区域动态更改组件的状态?

目前,我正在从序列化器渲染状态,但我想在拖放后动态更改它。

<draggable
  class="dragArea published"
  :options="{ group: { name: 'g1', put: 'g1'}, animation: 120 }"
  @end="onEnd">
    <div
      v-for="lesson in classroomLessonsPublished"
      :class="`lesson-card ${lesson.id}`"
      data-status="published">   
        <div> 
          {{ lesson.status }}
        </div>
    </div>
</draggable>

<draggable
  class="dragArea unpublished"
  :options="{ group: { name: 'g1', put: 'g1'}, animation: 120 }"
  @end="onEnd">
    <div
      v-for="lesson in classroomLessonsUnpublished"
      :class="`lesson-card ${lesson.id}`"
      data-status="unpublished">   
        <div> 
          {{ lesson.status }}
        </div>
   </div>
</draggable>

Run Code Online (Sandbox Code Playgroud)

vue.js vuedraggable

1
推荐指数
1
解决办法
1万
查看次数

从 vuex 商店排序数组(无限渲染警告)

我正在从 vuex 存储中检索一组对象,并且我试图在我的一个组件中对该数组进行排序(我不想在存储中对数组进行排序)。但是我的infinite update loop in a component render function浏览器出现错误。这里发生了什么,我该如何解决?

<template>
  <div
    v-for="(item, i) in itemList">
    {{item.description}}
  </div>
</template>


computed: Object.assign({},
  mapGetters({
    currentItemList: "item/current",
  }),
  {
   itemList() {
     if(this.currentItemList != undefined) {
       return this.currentItemList.sort(function(a, b) {
           var textA = a.description.toUpperCase()
           var textB = b.description.toUpperCase()
           return (textA < textB) ? -1 : (textA > textB) ? 1 : 0
         })
      }
      else {
        return []
      }
    },
  }
)
Run Code Online (Sandbox Code Playgroud)

vue.js

0
推荐指数
2
解决办法
1424
查看次数