属性'$'的对象(Property '$' of object)
我有一个Wordpress网站,最终是一个流媒体广播网站。 在标题我有一个脚本,从我的专用服务器的CP拉动流数据(如听众计数和当前正在播放)..(Centova演员)
我在function.php中注册了脚本:
这是登记册
wp_register_script('streaminfo','http://94.23.250.14:2199/system/streaminfo.js',false,null); wp_enqueue_script('streaminfo');
这是整个jQuery部分供您查看..
/* ------------------------------------ :: INITIATE JQUERY / STYLING ------------------------------------ */ function init_dynscripts() { if (!is_admin()) { if ( function_exists('bp_is_blog_page')) { if (!bp_is_blog_page()) { wp_enqueue_script( 'bp-js', BP_PLUGIN_URL . '/bp-themes/bp-default/_inc/global.js', array( 'jquery' ) ); } } wp_register_style('northvantage-style', get_bloginfo('stylesheet_url'),false,null); wp_enqueue_style('northvantage-style'); if(get_option('enable_responsive')!='disable') : wp_register_style('northvantage-responsive', get_template_directory_uri().'/stylesheets/responsive.css',false,null); wp_enqueue_style('northvantage-responsive'); endif; wp_enqueue_script('jquery-ui-core',false,null); wp_enqueue_script('jquery-ui-tabs',false,null); wp_enqueue_script("jquery-ui-accordion",false,null); wp_enqueue_script("swfobject",false,null); wp_deregister_script("jquery-effects-core"); wp_deregister_script('libertas'); wp_register_script('libertas',get_template_directory_uri().'/js/nv-script.pack.js',false,null); wp_enqueue_script('libertas'); wp_register_script( ’streaminfo’, 'http://94.23.250.14:2199/system/streaminfo.js',false,null); wp_enqueue_script( ’streaminfo’ ); wp_register_script( ’jpie’, get_template_directory_uri().'/js/jpie.js',false,null); wp_enqueue_script( ’jpie’ ); wp_register_style('jpiestyle', get_template_directory_uri().'/jpie.css',false,null); wp_enqueue_style('jpiestyle'); if(get_option('jwplayer_js')) { // Check jw player javascript file is present $NV_jwplayer_js = get_option('jwplayer_js'); wp_deregister_script( 'jw-player' ); wp_register_script( 'jw-player', $NV_jwplayer_js,false,null); wp_enqueue_script( 'jw-player' ); } } } add_action('init', 'init_dynscripts',100); function _remove_script_version( $src ){ // remove script version $parts = explode( '?', $src ); return $parts[0]; } add_filter( 'script_loader_src', '_remove_script_version', 15, 1 ); add_filter( 'style_loader_src', '_remove_script_version', 15, 1 );
看来我在streaminfo.js和我的网站之间有冲突。 元素检验给出:
未捕获的TypeError:对象[对象窗口]的属性'$'不是函数
简而言之......我尝试使用该文件的所有内容都错了。
我尝试将每个$符号更改为文件中的jQuery,它消除了冲突,但与其他文件产生冲突。
我尝试添加
jQuery(document).ready(function($){
到文件的头部,但它打破了CP上的其他元素。
最后,我运行了一个简单的测试并创建了一个只包含以下代码的网页:
<html> <body> <span id="cc_strinfo_title_tranceilfm" class="cc_streaminfo"></span> <script language="javascript" type="text/javascript" src="http://94.23.250.14:2199/system/streaminfo.js"></script> </body> </html>
并且页面没有返回任何错误。 (我确实包含了google jQuery文件的路径)
Wordpress中的东西搞砸了jQuery插件? 或者我的代码中缺少一些字符串?
www.tranceil.fm
I have a Wordpress website which eventually is a streaming radio website. on the header i have a script that is pulling streaming data (like listeners count and currently playing) from my Dedicated server's CP..(Centova Cast)
I registered the script in the function.php:
this is the register
wp_register_script( ’streaminfo’, 'http://94.23.250.14:2199/system/streaminfo.js',false,null); wp_enqueue_script( ’streaminfo’ );
This is the the whole jQuery section for you to review..
/* ------------------------------------ :: INITIATE JQUERY / STYLING ------------------------------------ */ function init_dynscripts() { if (!is_admin()) { if ( function_exists('bp_is_blog_page')) { if (!bp_is_blog_page()) { wp_enqueue_script( 'bp-js', BP_PLUGIN_URL . '/bp-themes/bp-default/_inc/global.js', array( 'jquery' ) ); } } wp_register_style('northvantage-style', get_bloginfo('stylesheet_url'),false,null); wp_enqueue_style('northvantage-style'); if(get_option('enable_responsive')!='disable') : wp_register_style('northvantage-responsive', get_template_directory_uri().'/stylesheets/responsive.css',false,null); wp_enqueue_style('northvantage-responsive'); endif; wp_enqueue_script('jquery-ui-core',false,null); wp_enqueue_script('jquery-ui-tabs',false,null); wp_enqueue_script("jquery-ui-accordion",false,null); wp_enqueue_script("swfobject",false,null); wp_deregister_script("jquery-effects-core"); wp_deregister_script('libertas'); wp_register_script('libertas',get_template_directory_uri().'/js/nv-script.pack.js',false,null); wp_enqueue_script('libertas'); wp_register_script( ’streaminfo’, 'http://94.23.250.14:2199/system/streaminfo.js',false,null); wp_enqueue_script( ’streaminfo’ ); wp_register_script( ’jpie’, get_template_directory_uri().'/js/jpie.js',false,null); wp_enqueue_script( ’jpie’ ); wp_register_style('jpiestyle', get_template_directory_uri().'/jpie.css',false,null); wp_enqueue_style('jpiestyle'); if(get_option('jwplayer_js')) { // Check jw player javascript file is present $NV_jwplayer_js = get_option('jwplayer_js'); wp_deregister_script( 'jw-player' ); wp_register_script( 'jw-player', $NV_jwplayer_js,false,null); wp_enqueue_script( 'jw-player' ); } } } add_action('init', 'init_dynscripts',100); function _remove_script_version( $src ){ // remove script version $parts = explode( '?', $src ); return $parts[0]; } add_filter( 'script_loader_src', '_remove_script_version', 15, 1 ); add_filter( 'style_loader_src', '_remove_script_version', 15, 1 );
It appears i have a conflict between streaminfo.js and my website. element inspection gives:
Uncaught TypeError: Property '$' of object [object Window] is not a function
To make things short..everything i tried with the file ended up wrong.
i tried changing every $ sign to jQuery in the file, it eliminate the conflict but created conflicts with other files.
i tried adding
jQuery(document).ready(function ($) {
to the head of the file but it breaks other elements on the CP.
Eventually i ran a simple test and created a webpage with only this code:
<html> <body> <span id="cc_strinfo_title_tranceilfm" class="cc_streaminfo"></span> <script language="javascript" type="text/javascript" src="http://94.23.250.14:2199/system/streaminfo.js"></script> </body> </html>
And the page didn't return any errors. (i did include a path to the google jQuery file)
Something in Wordpress is messing up with the jQuery plugin? or some string is missing in my code?
www.tranceil.fm
原文:https://stackoverflow.com/questions/11764154
最满意答案
您无法对
list
的元素进行ref
,更改ref
,然后期望list
的项目发生更改。 如果您真的想这样做,那么您应该将引用放入Tree
类型中。type Tree = |Node of string*list<Tree ref> |Empty let rec branchToTree (inputList:list<string>) = match inputList with | [] -> Tree.Empty | head::tail -> Tree.Node(head, [ref (branchToTree tail)])
如果你这样做,删除
List.map (fun(child) -> ref child)
部分,然后你的代码就可以了。您可能对拉链感兴趣,它允许您做类似但没有变异的事情。
You can't make a
ref
to an element in alist
, change theref
and then expect the item in thelist
to change. If you really want to do that then you should put the references into yourTree
type.type Tree = |Node of string*list<Tree ref> |Empty let rec branchToTree (inputList:list<string>) = match inputList with | [] -> Tree.Empty | head::tail -> Tree.Node(head, [ref (branchToTree tail)])
If you do that, remove the
List.map (fun(child) -> ref child)
part then your code works.You might be interested in zippers which allow you to do something similar but without mutation.
相关问答
更多-
沈阳好的电脑培训学校????[2022-03-12]
f -
使用F#实现树构建器(Implement tree builder with F#)[2023-03-14]
您无法对list的元素进行ref ,更改ref ,然后期望list的项目发生更改。 如果您真的想这样做,那么您应该将引用放入Tree类型中。 type Tree = |Node of string*list|Empty let rec branchToTree (inputList:list ) = match inputList with | [] -> Tree.Empty | head::tail -> T ... -
是否有F#活动的建设者?(Is there a builder for F# events?)[2022-05-13]
托马斯在这里做了一些研究 ,这似乎是一个富有成效的途径。 Tomas has done some research here, and this does seem a fruitful avenue. -
F#树:节点插入(F# Tree: Node Insertion)[2022-01-18]
在您的评论之后,这里的代码将按预期运行: let insert pntName (Person(_, newPrsnYear, _) as newPrsn) (Person (n,y,ch)) = let rec ins n y = function | [] -> if y < newPrsnYear && n = pntName then Some [newPrsn] else None | (Person (name, year, childs) as pers ... -
f#访问树的根元素(f# access root element of a tree)[2021-11-02]
这个怎么样: let rootValue (Node(_,v,_)) = v 如果树为空,这将抛出异常。 或者: let tryGetRootValue = function | Node(_,v,_) -> Some v | _ -> None 这将始终成功,但将返回float option而不是float 。 How about this: let rootValue (Node(_,v,_)) = v This will throw an exception if the tree is emp ... -
您收到错误是因为None匹配返回Some Node ,因此您必须在所有其他分支中匹配该返回类型。 您可以通过在匹配后返回节点来解决其他匹配中的问题: let rec Add (node:Node option) value = match node with | None -> Some { Left = None; Right = None; Value = value; Count = 1 } | Some t -> match t with ...
-
最后我看,表现非常糟糕,比F#慢50倍,甚至比天真的翻译慢。 坦率地说,我不明白他们为什么不将F#编译器本身暴露为运行时服务(和FSI)。 如果他们做了F#,他们现在会有更好的工具...... 编辑:我昨晚对运行斐波那契函数的报价进行了基准测试,实际上是700倍! Last I looked, the performance was absolutely awful, around 50× slower than F# and even slower than a naive interpreter. Fr ...
-
将JSON多路树解码为F#多路树识别联盟(Decode JSON Multiway Tree into an F# Multiway Tree Discriminated Union)[2023-09-18]
考虑这一点的一种方法是查看构建CommentMultiTreeDatabaseModel 。 它需要CommentDatabaseModel和CommentMultiTreeDatabaseModel列表。 所以我们需要编写以下两个函数: let parseComment (input : JSON) : CommentDatabaseModel = ... let parseTree (input : JSON) : CommentMultiTreeDatabaseModel = ... ... -
Rx的F#工作流构建器(F# workflow builder for Rx)[2024-01-30]
首先,需要针对最新的Rx版本稍微更新原始代码。 也就是说, For和While应该实现为: member this.For (xs : 'a seq, f: 'a -> 'b IObservable) = Observable.SelectMany(xs.ToObservable(), new Func<_, IObservable<_>>(f)) member this.While (f, xs: 'a IObservable) = Observable.TakeWhile (xs, ...