我有一个组件的引用
<Gmap ref="mapRef">
Run Code Online (Sandbox Code Playgroud)
在安装中,我正在这样做,只是为了查看对象可用
mounted(){
let self = this
console.log(self.$refs) // Shows the mapRef object reference
console.log(self.$refs.mapRef) // returns undefined ???
}
Run Code Online (Sandbox Code Playgroud)
self.$refs 显示...
mapRef: VueComponent {_uid: 207, _isVue: true, $options: {…}, _renderProxy: Proxy, _self: VueComponent, …}
Run Code Online (Sandbox Code Playgroud)
那么为什么 self.$refs.mapRef 返回 undefined 呢??即使它明显在那里??
如何将条带检出模式框中的文本从PAY更改为其他内容.
我知道我可以在弹出模态的按钮上做自定义文本.
description: 'ADD CARD',
label:'ADD CARD',
Run Code Online (Sandbox Code Playgroud)
但在实际的模态窗口.它仍然只是按下PAY.我想要它说ADD CARD.
我有一个清单
<li v-for="menu_item, key in menu" @click="clickMenu(key)" :ref="'menu'+key">
{{menu_item.name}}
</li>
Run Code Online (Sandbox Code Playgroud)
在我的 vue 中,我有
mounted(){
// This shows the $refs as being mounted and available
console.log(this.$refs)
console.log(this.$refs.menu1)
// Click menu item 2 seconds after mounting
this.$refs.menu1.click()
// click is UNDEFINED
},
methods: {
clickMenu:function(key){
console.log("CLICKED "+key)
},
}
Run Code Online (Sandbox Code Playgroud)
我收到“无法读取未定义的属性‘点击’”
我如何简单地以编程方式触发元素上的点击?
Github 上的另一个答案说我应该做...
this.$refs.menu1.$el.click()
Run Code Online (Sandbox Code Playgroud)
但这也没有定义??
继承人一个 JSFiddle 希望有人能在这里弄清楚 JSFIDDLE !
我试图对一个物体施加一个力.使它以我的鼠标位置相对于对象生成的角度移动.
我有角度
targetAngle = Matter.Vector.angle(myBody.pos, mouse.position);
Run Code Online (Sandbox Code Playgroud)
现在我需要施加一个力,让身体沿着那个角度移动.对于applyForce方法,我在下面的值中添加了什么?
// applyForce(body, position, force)
Body.applyForce(myBody, {
x : ??, y : ??
},{
x:??, y: ?? // how do I derive this force??
});
Run Code Online (Sandbox Code Playgroud)
我在这里放入x和y值以使身体沿着鼠标和身体之间的角度移动.
我一直在使用ngrok在我的手机上测试一个应用程序,在过去两周内反应原生.到目前为止,它已经非常体面和快速.
直到今天.现在它突然需要大约50秒才能从我的手机,我的本地主机和后面进行往返请求.或者从我的浏览器,到ngrok隧道,回到我的localhost.
起初我想,好吧ngrok要么已经失败,要么正在经历减速.但后来我决定用Postman打它,并且请求很快.大约0.5秒.当我访问隧道统计信息时也是如此.重播请求就像1秒.
就在我通过手机或浏览器进行操作时,它现在非常慢.这可能突然发生的具体原因是什么?任何人都可以了解我应该开始寻找的地方吗?
我尝试重新启动,并刷新DNS,但无济于事.
如何使用Vue.js播放声音?
似乎我不能按常规方式做。
import Vue from 'vue'
import AppView from './components/App.vue'
console.log('Play outside of vue')
var audio = new Audio('file.mp3')
audio.play()
new Vue({
el: '#root',
mounted () {
console.log('Will it play here?? lol')
var audio = new Audio('file.mp3')
audio.play()
},
render: h => h(AppView)
})
Run Code Online (Sandbox Code Playgroud)
如它所说,音频未定义?我是否必须以某种方式导入它?是否有特定的Vue软件包?还是npm包?
我真的不明白,尽管Audio只是普通的javascript吗?
我有一个复选框数组,它们来自存储所有系统设置的主系统对象。(称为getSystem {})。
我以这种形式访问具有一系列角色[]的用户。如何对照getSystem.user_roles检查此角色数组?
我知道如何正常做,显然是在javascript中。但是我应该在复选框输入Vue.js中添加什么呢?
<b-form-group>
<label for="company">Email Address</label>
<b-form-input type="text" id="email" v-model="user.email" placeholder="Enter a valid e-mail"></b-form-input>
</b-form-group>
// Here i can do user.roles to get the array of roles.
// What can I do to loop through the roles and check the box if it exists in the user roles??
<b-form-group v-for="resource, key in getSystem.user_roles" v-if="getSystem.user_roles">
<label>{{resource.role_name}}</label>
<input type="checkbox" [ what do I put here to compare against user.roles, and check the box if exists??] >
</b-form-group>
Run Code Online (Sandbox Code Playgroud) 我使用谷歌登录,并且在本地运行良好。但是当我把它放在服务器上并尝试登录时我得到了
'Uncaught: popup closed by user'
Run Code Online (Sandbox Code Playgroud)
我已经禁用了我的广告拦截器以及任何可能干扰的东西。但仍然收到错误。
我使用 Vuejs 登录,并且我知道所有代码都有效,因为我可以在本地登录。
无论如何,我都会发布代码,尽管我很确定这不是问题所在。我的 Vue.js 登录方法是...
clickButton(type) {
var that = this
that.signType = type
auth2.grantOfflineAccess({ 'redirect_uri': 'postmessage', 'approval_prompt': 'force' }).then(that.onSignIn);
},
// Callback for Sign In
onSignIn(authResult) {
if (authResult.code) {
this.$store.dispatch(TYPES.GET_GOOGLE_TOKEN, { code: authResult.code })
}
},
Run Code Online (Sandbox Code Playgroud) 我正在尝试运行一个在服务器上运行物理模拟的服务器,并让客户端通过 websockets/socket.io 连接到该服务器。我知道我可以使用 Matter.js 与渲染分开计算引擎。所以我的问题是,如何将引擎数据发送给客户端?
我有一个Game类,在套接字连接上,我想将其发送World给客户端进行渲染。
var g = new Game()
g.initEngine()
io.sockets.on('connection', function(socket) {
io.emit('gamestate', g.getGameState())
});
Run Code Online (Sandbox Code Playgroud)
在游戏状态下,我不太确定要传递什么:
var Game = function(Player1, Player2) {
var self = this
this.gameID = 22
this.engine = null
this.world = null
// Get game state - WHAT DO I SEND HERE!??
this.getGameState = function() {
return self.engine
}
// Create the engine
this.initEngine = function() {
self.engine = M.Engine.create();
self.world = self.engine.world;
self.world.gravity.x = 0;
self.world.gravity.y = 0;
M.Engine.update(self.engine, …Run Code Online (Sandbox Code Playgroud) 如何从后到前迭代 javascript 对象。
对象看起来像这样。 {"33":140, "34":100, "35":120, "36":200}
我希望它像这样显示...
36 | 200
35 | 120
34 | 100
33 | 140
Run Code Online (Sandbox Code Playgroud)
我尝试先排序然后显示,但它按第二个数字而不是键排序。我将如何从后到前迭代,或者根据键进行反向排序。
我意识到这很简单,但我对此感到非常沮丧......