我正在尝试将一个简单的日期选择器添加到自定义vue组件.我没有使用webpack,所以我想避免现成的.vue组件,而我更了解如何添加简单的javascript到vue.
我正在关注这个官方的vue教程
我也看过这个代码,但我无法设法让日期选择器出现.
这是我的jsfiddle:
HTML:
<div class="app">
<datepicker id='date-elem'></datepicker>
</div>
Run Code Online (Sandbox Code Playgroud)
app.js:
Vue.component('date-picker', {
extends: Flatpickr,
mounted () {
this.Flatpickr(date-elem, {})}
})
Run Code Online (Sandbox Code Playgroud)
如何在不需要.vue文件,webpack等的情况下轻松地将vanilla js集成到Vue组件中?
我正在尝试让django和Vue一起工作,即使它们共享相同的{{X}}模板语法.
我知道从django 1.5我们可以使用{% verbatim %}标签.所以我认为我可以像往常一样使用django模板,在我需要VUE接管的部分中,我只使用{%verbatim%}标签.然而,而不是加载我的vue数据django加载{{ variable }}.
例如,我的django代码看起来像这样:
{% verbatim %}
<div id='sessions'>
<h2>{{message}}</h2>
</div>
{% endverbatim %}
Run Code Online (Sandbox Code Playgroud)
在我的app.js文件中,我有:
var sessions = new Vue({
el: '#sessions',
data: {
message: 'Hello Vue!'
}
})
Run Code Online (Sandbox Code Playgroud)
但不是呈现Hello Vue!它渲染{{message}}
控制台不会显示任何错误,否则vue会正确加载.
我怎么能让两者一起工作?理想情况下无需更改vue.js {{}}语法.
我将代码库移到了dockerformat.
我有一个docker-compose文件,其中包含以下命令:
command: bash -c "rm -rf node_modules && npm install && npm run dev"
一切正常,我使用rm -rf node_modules是因为它给了我一些丢失包的错误(来自我的MAC).这样做只是重新创建它在localhost上正常工作.
我还添加了卷,所以当我在我的代码中更改某些东西时会反映在我的容器中,这也可以正常工作(除了热重载,但这不是什么大问题).
现在我通常只是注释掉这行:command: bash -c "rm -rf node_modules && npm install && npm run dev"在我的docker-compose文件上,而是添加:
command: bash -c "rm -rf node_modules && npm install && npm run build"来构建我的包,所以在生产中我根本没有节点,但是这没有给我带来任何结果.
我不确定它是否是卷的问题,即它是在容器中构建但我无法从我的机器访问它(我不认为因为我本地机器中的代码更改会反映在我的容器中)或者由于某种原因它根本没有建成.
这是输出 command: bash -c "rm -rf node_modules && npm install && npm run build --verbose"
NODE | npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.3 (node_modules/fsevents):
NODE | npm WARN …Run Code Online (Sandbox Code Playgroud) 我正在尝试从此格式重定向网址:
http://localhost:8080/setup/xyz/?code=some-code
对此:
http://localhost:8080/app/#/setup/xyz/?code=some-code
我已经尝试过代理和重写:
historyApiFallback: {
rewrites: [
{ from: /^\/$/, to: '/index.html' },
{ from: /^\/app/, to: '/app.html' },
{ from: /^\/setup/, to: '/app/#/setup' },
]
Run Code Online (Sandbox Code Playgroud)
},
但它似乎不起作用。有没有办法使用开发服务器编写 301 重定向?
我在我的应用程序中集成了对讲机,我需要window.Intercom('update');每次更改我的网址.
我知道我可以添加它mounted()但我宁愿不修改我的所有组件并使用导航警卫直接进行.(主要是为了避免在10个不同的地方使用相同的代码.
目前我有:
router.afterEach((to, from) => {
eventHub.$off(); // I use this for an other things, here is not important
console.log(window.location.href ) // this prints the previous url
window.Intercom('update'); // which means that this also uses the previous url
})
Run Code Online (Sandbox Code Playgroud)
这intercom('update')在更改url之前运行,而我需要在url更改后运行它.
是否有一个挂钩,当网址发生变化时才会运行?我怎样才能做到这一点?
谢谢
我正在尝试使用 python sdk 获取广告最终 url。
我尝试了所有字段,但无法找到返回广告网址的字段。目前我的领域是:
params = {'access_token':creds.refresh_token,
'fields':'action_values, actions, ad_name, adset_name, objective, outbound_clicks, outbound_clicks_ctr, call_to_action_clicks, campaign_name, cost_per_unique_click, cpc, cpm, spend, website_ctr, date_start, date_stop',
'action_breakdowns':['action_link_click_destination'],
'date_presets':'last_year',
# 'time_range':" since:2017-06-01, until:2017-01-03}"
}
ad_insights = requests.get("https://graph.facebook.com/v2.10/{}/insights".format(ad['id']), params=params)
Run Code Online (Sandbox Code Playgroud)
我知道有些广告没有最终网址,例如速推帖子,但许多广告仅指向一个网站,我如何获得“号召性用语网址”?
我有一个非常简单的字典,上面有一些数据:
some_data= {'totalsForAllResults': {'ga:sessions': '11'}, 'profileInfo': {'internalWebPropertyId': '104132673', 'accountId': '67836206', 'profileName': 'My New Cool Site', 'webPropertyId': 'UA-677293506-1', 'profileId': '108628346', 'tableId': 'ga:108372846'},
Run Code Online (Sandbox Code Playgroud)
我的观点是:
sessions = some_data['totalsForAllResults']['ga:sessions']
account_id = some_data['profileInfo']['accountId']
property_id = some_data['profileInfo']['internalWebPropertyId']
property_name = some_data['profileInfo']['profileName']
print(sessions,account_id,property_id,property_name)
return render(request, 'ga_app/report.html', {'sessions':sessions},
{'account_id':account_id},
{'property_id':property_id},
{'property_name':property_name},)
Run Code Online (Sandbox Code Playgroud)
变量完美地打印在我的外壳上,但是 django 不想将它们传递给模板,我不断收到TypeError: unhashable type: 'dict'但我将变量发送到模板而不是字典。为什么会发生这种情况?
我正在尝试将函数调用到 django 中的函数中,但我不断收到:
The view app.views.function1 didn't return an HttpResponse object. It returned None instead.
Run Code Online (Sandbox Code Playgroud)
我的观点是:
def function1(request):
[some api calls]
#Once this process is done I want to call my second function
function2()
Run Code Online (Sandbox Code Playgroud)
然后我有
def function2(request):
Run Code Online (Sandbox Code Playgroud)
如何轻松调用 Django/Python 中的其他函数
ps 这些函数可能只是一个,我只是想将它们分开以使我的代码更具可读性并且让一个函数只做一件事。
我有一个简单的 css 框,由以下内容制成:
border: 1px solid #CCC;
Run Code Online (Sandbox Code Playgroud)
我正在尝试从文本左侧到边框添加一些空间。我尝试过使用marginsandpadding但它总是在盒子外面,而我希望里面有一些边距。
我框内的文本始终附加在左侧,如何在文本和框之间添加一些边距/空间?
我有代码: https: //jsfiddle.net/z2v27rcq/如果有帮助的话。
我正在尝试将一些数据保存到我的数据库中,但我不断收到错误消息:'tuple' object has no attribute 'view_id我认为不知何故我从我的数据库中错误地获取了对象。
模型.py
class GoogleProperty(models.Model): # Settings for each single site, a user can have many!
user = models.CharField(max_length=200) # Owner of site
google_email = models.EmailField(max_length=200)
profile_id = models.CharField(max_length=200) # Needed to delete users, but should be removed!
property_name = models.CharField(max_length=200, blank=True, null=True)
property_id = models.CharField(max_length=200, blank=True, null=True)
property_url = models.CharField(max_length=200, blank=True, null=True)
view_id = models.CharField(max_length=200)
def __str__(self):
return str(self.property_url)
Run Code Online (Sandbox Code Playgroud)
视图.py
def some_function(requests):
if len(list_of_views)==1: # Save to DB and call it a day …Run Code Online (Sandbox Code Playgroud)